Programmatically Configure Jetty Logger

How to programmatically configure a Jetty logger? I am using Jetty in a standalone application and want to change the log level of some Jetty built-in alerts. Ideally, I could do this programmatically (i.e. in code) without specifying an XML file.

I am using Jetty 6.1.20.

+4
source share
2 answers

Jetty uses slf4j , so you can use any logging framework or slf4j implementation you want.

Jetty comes with a simple slf4j implementation that records INFO levels or higher. Thus, you either modify the associated slf4j packages with the implementation with the required log levels, or use a bridge for another structure with the required log levels or provide your own log class, which you can set, for example,

System.setProperty("org.mortbay.log.class", "com.example.JettyLog"); 

More details here .

+3
source

If you need to get query logs, the solution will only be at http://www.eclipse.org/jetty/documentation/current/configuring-jetty-request-logs.html

 NCSARequestLog requestLog = new NCSARequestLog("/var/logs/jetty/jetty-yyyy_mm_dd.request.log"); requestLog.setAppend(true); requestLog.setExtended(true); requestLog.setLogTimeZone("GMT"); server.setRequestLog(requestLog); 
+1
source

All Articles