Hello.

I have multiple microservices, some run on Tomcat some are standalone jars. We used to log using java.util.logging framework. Later we made switch to Log4j2 (+ JUL adapter), but kept the JUL API for logging as to not to have to rewrite the code. This works (and it can not be changed although I would like to). Obviously there is some log level translation as JUL and Log4j2 use different log level. In non-Tomcat services, log levels look like this:

14:49:58.612 FINEST -            t1     Log level FINEST enabled
14:49:58.612 TRACE  -            t1     Log level FINER enabled
14:49:58.613 DEBUG  -            t1     Log level FINE enabled
14:49:58.613 CONFIG -            t1     Log level CONFIG enabled
14:49:58.613 INFO   -            t1     Log level INFO enabled
14:49:58.613 WARN   -            t1     Log level WARNING enabled
14:49:58.614 ERROR  -            t1     Log level SEVERE enabled
This is expected behavior.

However, on Tomcat, we get this:

14:46:38.393 TRACE  -            t1     Log level FINEST enabled
14:46:38.394 DEBUG  -            t1     Log level FINER enabled
14:46:38.394 DEBUG  -            t1     Log level FINE enabled
14:46:38.395 INFO   -            t1     Log level CONFIG enabled
14:46:38.396 INFO   -            t1     Log level INFO enabled
14:46:38.396 WARN   -            t1     Log level WARNING enabled
14:46:38.397 ERROR  -            t1     Log level SEVERE enabled

This is not correct. I belive it has something to do with the translation from-to JUL, since Tomcat's JULI is based on JUL.

In order to confirm my suspicion, I have switched Tomcat to use Log4j2 also for it's internal logging, which solved the log level issue but brought another. Thread context is not injected to Log4j2 logs anymore. I suspect it is because there are now running 2 Log4j instances - one for Tomcat and one for our app.

To solve my issue, I would be happy with either of the solutions

- Fix Tomcat using JULI to show correct Log4j2 log levels or
- Use Tomcat with Log4j instead of JULI but keep ThreadContext working

First one is preferred solution if possible.

Thanks for any suggestions.


--
Best regards,
Martin Dratva


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to