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

logback configuration defined via JAVA_TOOL_OPTIONS is ignored #8596

Closed
vekonypeter opened this issue Jan 10, 2023 · 4 comments · Fixed by #9009
Closed

logback configuration defined via JAVA_TOOL_OPTIONS is ignored #8596

vekonypeter opened this issue Jan 10, 2023 · 4 comments · Fixed by #9009
Assignees
Labels
type: bug Something isn't working
Milestone

Comments

@vekonypeter
Copy link

Expected Behavior

When the path to the logback.xml file is defined in the JAVA_TOOL_OPTIONS environment variable (like e.g.: JAVA_TOOL_OPTIONS=-Dlogback.configurationFile=/path/to/logback-external.xml) this configuration should be used

Actual Behaviour

The external logback XML file is used as expected until the end of the bean registration phase. From that point, the framework switches back to the default logback.xml file placed under the resources folder.

This behaviour was introduced in PR #8238, it's caused by this method: https://github.com/micronaut-projects/micronaut-core/blob/3.8.x/management/src/main/java/io/micronaut/management/endpoint/loggers/impl/LogbackLoggingSystem.java#L135-L149

Steps To Reproduce

  1. define e.g. logback-external.xml file either in the resources folder or anywhere else. Make sure that it logs somehow differently than the default logback.xml.
  2. run the application with JAVA_TOOL_OPTIONS=-Dlogback.configurationFile=/path/to/logback-external.xml environment variable
  3. configuration defined in logback-external.xml is ignored once the application started up

Environment Information

  • Micronaut version: 3.8.0 - everything works fine below that
  • Operating system: MacOS
  • JVM: Temurin-17.0.5+8

Example Application

No response

Version

3.8.0

@driverpt
Copy link
Contributor

Try to set -Dlogger.config=/path/to/logback-external.xml.

@adamkobor
Copy link
Contributor

@driverpt Unfortunately this doesn't work if the config file is not on your classpath (e.g. attached through a volume in the container)

@ckosmowski
Copy link

This is also a real issue for us because we use this feature to inject logback configuration in a kubernetes environment and with an update to 3.8.x the services won't start up anymore complaining about logback.xml is mssing.

@albrechtflo-hg
Copy link

albrechtflo-hg commented Mar 24, 2023

I checked out the LogbackUtils code which loads the config into Logback, and I really cannot understand why this is limited to the Classpath. The resource is mapped to a URL anyway in that class, so why not use just a little cleverer approach to look up the resource?
@driverpt @graemerocher This should really be looked into, as it really is a huge regression when upgrading Micronaut.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

8 participants