Open mpdude opened 5 years ago
Unfortunately there is no such switch currently. Your best bet is to use a filter.
It looks like Jetty has a facility for this. From https://www.eclipse.org/jetty/documentation/9.4.x/configuring-jetty-request-logs.html :
NCSARequestLog requestLog = new NCSARequestLog("/var/logs/jetty/jetty-yyyy_mm_dd.request.log");
requestLog.setAppend(true);
requestLog.setExtended(false);
requestLog.setLogTimeZone("GMT");
requestLog.setLogLatency(true);
requestLog.setRetainDays("90");
server.setRequestLog(requestLog);
You would have to add this in a custom JettyServerFactory.
There is a sample to add a NCSA logger on Spark 2.7.2 in this repo : https://github.com/ygaller/spark-with-request-logger
Would be really nice to have this as a default method that one can call. It's kinda weird to need to add this much code to turn on request logging :/
Is there an easy way to enable request logging, say by just flipping a configuration switch?
What I‘m after is something like the „Common Log Format“, that is, a lot entry for every request with the HTTP response code, User Agent, requested URI and such.
I guess this must be possible somehow, without assembling all this information manually in a filter?