Skip to content

Slf4JLoggingSystem should also configure JUL levels #2923

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

Closed
farrault opened this issue May 6, 2015 · 8 comments
Closed

Slf4JLoggingSystem should also configure JUL levels #2923

farrault opened this issue May 6, 2015 · 8 comments
Assignees

Comments

@farrault
Copy link

farrault commented May 6, 2015

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

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

"logging.level.xxx" 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
@trecloux
Copy link

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 added for: team-attention An issue we'd like other members of the team to review and removed for: team-attention An issue we'd like other members of the team to review labels May 25, 2016
@philwebb philwebb removed this from the 1.4.0.RC1 milestone May 25, 2016
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 25, 2016
@philwebb
Copy link
Member

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.

@philwebb philwebb closed this as completed Jan 9, 2017
@philwebb philwebb added status: duplicate A duplicate of another issue and removed for: team-meeting status: waiting-for-triage An issue we've not yet triaged labels Jan 9, 2017
@mmoayyed
Copy link
Contributor

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/logging.properties

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?

@philwebb philwebb reopened this Apr 4, 2017
@philwebb philwebb added status: waiting-for-triage An issue we've not yet triaged and removed status: duplicate A duplicate of another issue labels Apr 4, 2017
@philwebb
Copy link
Member

philwebb commented Apr 4, 2017

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

@philwebb philwebb added the status: waiting-for-feedback We need additional information before we can continue label Apr 4, 2017
@mmoayyed
Copy link
Contributor

mmoayyed commented Apr 5, 2017

Sure. This is where I started out originally: https://github.com/apereo/cas-overlay-template

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 cas.properties file or the application.yml file and that exhibits the same behavior.

You can also very easily duplicate this with start.spring.io. 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 application.properties file to have: logging.level.org.apache=DEBUG.
  4. Package and build. Notice the absence of DEBUG logs in the console. Note that if I skip step [BS-157] Add support for MultipartConfig #2, I can perfectly see DEBUG data when logback is used.

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

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Apr 5, 2017
@wilkinsona wilkinsona added type: bug A general bug and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Sep 29, 2017
@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
@wilkinsona
Copy link
Member

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.

@hbahramiyan

This comment has been minimized.

@wilkinsona

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants