简体   繁体   中英

Log4J Integration for Embedded Jetty

I am using an embedded jetty and log4j . In my project I have log4j.properties file for managing my logs. It looks like the following:

org.eclipse.jetty.util.log.Slf4jLog =DEBUG, consoleAppender

log4j.rootLogger=INFO, consoleAppender, fileAppender

The problem is that the first line, which should define jetty's log level does not work. Due to my rootlogger I get the message

INFO  org.eclipse.jetty.util.log  - Logging initialized @11716ms to org.eclipse.jetty.util.log.Slf4jLog

additionally, I tried:

log4j.category.org.eclipse.jetty.util.log.Slf4jLog

So jetty seems to detect slf4jlog and the root logging is working. Now I want to write a special log level for jetty. If I only put the first line to log4j.properties then I do not get any output. I also tried to prefix the firstline with log4j: log4j.org.eclipse.jetty.util.log.Slf4jLog =DEBUG, consoleAppender which is still not working.I simply do not get any output....

org.eclipse.jetty.util.log.Slf4jLog =DEBUG, consoleAppender

The class org.eclipse.jetty.util.log.Slf4jLog has no debug level logging events on that logger name. You will not see DEBUG level logging events on that logger name.

That's just a bridge class from Jetty logging facade to Slf4j logging facade (which then routes to your Log4J implementation).

Each instance of org.eclipse.jetty.util.log.Slf4jLog will have a specific declared logger name that those events will be emitted on.

Have you tried just....

log4j.category.org.eclipse.jetty=DEBUG, consoleAppender

That will put all loggers that start with org.eclipse.jetty into DEBUG level appending to your configured logger called consoleAppender

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM