Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slf4JLoggingSystem should also configure JUL levels #2923

farrault opened this issue May 6, 2015 · 8 comments


Copy link

@farrault farrault commented May 6, 2015

As discussed here, by default SLF4JBridgeHandler only receives INFO or higher JUL logs

And so, enabled lower levels in with "" properties doesn't allow to see JUL logs lower than INFO

"" properties should also be applied to JUL loggers (in addition to Sl4jf loggers) in order to SLF4JBridgeHandler to receive all the enabled logs

@philwebb philwebb added this to the 1.4.0 milestone Jul 10, 2015

This comment has been minimized.

Copy link

@trecloux trecloux commented Sep 26, 2015

If you are using logback, JUL should now also be configured : #3926

@philwebb philwebb modified the milestones: 1.4.0.M2, 1.4.0 Jan 7, 2016
@philwebb philwebb modified the milestones: 1.4.0.M3, 1.4.0.M2 Apr 12, 2016
@philwebb philwebb modified the milestones: 1.4.0.RC1, 1.4.0.M3 May 17, 2016
@philwebb philwebb removed this from the 1.4.0.RC1 milestone May 25, 2016

This comment has been minimized.

Copy link

@philwebb philwebb commented Jan 9, 2017

I think this should be fixed by #3926. If you're still having the problem with the latest release please let us know.


This comment has been minimized.

Copy link

@mmoayyed mmoayyed commented Apr 3, 2017

@philwebb per your last comment, I am writing back to report that this issue is still present in Spring Boot 1.5.2 using Log4j2. The only way to get messages from JUL that are below INFO is to use the following trick:

java -jar ... -Djava.util.logging.config.file=/path/to/

where as an example:

handlers = java.util.logging.ConsoleHandler
.level = ALL
java.util.logging.ConsoleHandler.level = DEBUG
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

What can I do to assist with troubleshooting and resolution of this problem?


This comment has been minimized.

Copy link

@philwebb philwebb commented Apr 4, 2017

@mmoayyed Do you have a sample you can share that shows the problem?


This comment has been minimized.

Copy link

@mmoayyed mmoayyed commented Apr 5, 2017

Sure. This is where I started out originally:

There are instructions on the README that explain what one must do to build and deploy. What I can see that once I modify the /etc/cas/config/log4j2.xml file to open up logging to TRACE for anything under org.apache, I don't ever get any Tomcat-related logs below INFO. I can apply the same sort of logging change to the file or the application.yml file and that exhibits the same behavior.

You can also very easily duplicate this with Here's what I did:

  1. Generate a project selecting only the web dependency.
  2. Exclude the logging starter module, and use the one for log4j2 per the docs.
  3. Change file to have:
  4. Package and build. Notice the absence of DEBUG logs in the console. Note that if I skip step #2, I can perfectly see DEBUG data when logback is used.

You can also use which is my attempt at duplicating this issue with 1-4 combined.

@wilkinsona wilkinsona added this to the 2.0.0.RC1 milestone Sep 29, 2017
@philwebb philwebb modified the milestones: 2.0.0.M7, 2.0.0.RC1 Nov 8, 2017
@wilkinsona wilkinsona self-assigned this Jan 5, 2018

This comment has been minimized.

Copy link

@wilkinsona wilkinsona commented Jan 17, 2018

Thanks for the sample. Given the lack of a Log4j equivalent of Logback's LevelChangePropagator, there's no easy way for us to propagate Log4j log levels into JUL.

Instead, the recommended approach with Log4j is to configure the use of org.apache.logging.log4j.jul.LogManager via the java.util.logging.manager system property. This has to be done before any calls to JUL are made. We fine-tuned Boot's use of JUL in 1.5.5 (#9848) so that it's not used until classes from dependencies nested in a fat jar can be loaded.

This approach works well with the provided sample if you upgrade to Spring Boot 1.5.5 or later (I used 1.5.9), add a dependency on org.apache.logging.log4j:log4j-jul, and launch the app with the required system property:

$ java -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager -jar target/demo-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 :: Spring Boot ::        (v1.5.9.RELEASE)

2018-01-17 21:12:56.729  INFO 56307 --- [           main] c.e.DemoApplication                      : Starting DemoApplication v0.0.1-SNAPSHOT on aw-rmbp.local with PID 56307 (/Users/awilkinson/Downloads/gh-2923/demo/target/demo-0.0.1-SNAPSHOT.jar started by awilkinson in /Users/awilkinson/Downloads/gh-2923/demo)
2018-01-17 21:12:56.734  INFO 56307 --- [           main] c.e.DemoApplication                      : No active profile set, falling back to default profiles: default
2018-01-17 21:12:56.791  INFO 56307 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4cc77c2e: startup date [Wed Jan 17 21:12:56 GMT 2018]; root of context hierarchy
2018-01-17 21:12:56.800 DEBUG 56307 --- [kground-preinit] o.a.t.u.m.Registry                       : Found jar:file:/Users/awilkinson/Downloads/gh-2923/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/tomcat-embed-core-8.5.23.jar!/org/apache/catalina/mbeans/mbeans-descriptors.xml
2018-01-17 21:12:56.812 DEBUG 56307 --- [kground-preinit] o.a.t.u.d.Digester                       : register('-//Apache Software Foundation//DTD Model MBeans Configuration File', 'jar:file:/Users/awilkinson/Downloads/gh-2923/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/tomcat-embed-core-8.5.23.jar!/org/apache/tomcat/util/modeler/mbeans-descriptors.dtd'

The need to use a system property makes me wary of enabling this by default, but we could add something to the relevant section of the documentation. I've opened #11660 to do so.


This comment was marked as off-topic.

Copy link

@HMD3731 HMD3731 commented Sep 18, 2018

how should i config log4j2 to stores tomcat logs into a file?!


This comment was marked as off-topic.

Copy link

@wilkinsona wilkinsona commented Sep 18, 2018

@HMD3731 Please ask questions on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
8 participants
You can’t perform that action at this time.