-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Document logger environment variable restrictions #17958
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
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I'm trying to think how we can fix this. One option would be to try and make all logger lookups case-insensitive, but I'm really not sure how we can do that. Another might be try and find a class name that matches the logger name (using some case-insensitive search) then use the found class name to get the correct case back. I'll flag this one for team attention to see if anyone else has some bright ideas. |
With both Logback (a list of loggers) and Log4j2 (a map of name -> logger config) it is possible to perform a case insensitive match for existing loggers when setting a log level. However, that would not help when the level is being set before the logger has been created. Setting the level would then create the logger with a name that does not match the one used in application code. We could further refine this by trying to find a class name that is a case-insensitive match for the logger name as @philwebb suggests above. Other than using |
See also #17975 for another issue that would be impossible to set in environment variables. |
We'll make this one a documentation issue since there's no easy fix. I've opened #18003 to see if we can't come up with a better long term solution. |
I'm trying to configure log level for a concrete logger using environment variable, but am unable to do so since binding doesn't appear to work correctly in this case.
This can be easily reproduce using a simple Spring Boot application consisting of only
spring-boot-starter-web
. For example, setting log level fororg.springframework.web.context
usingLOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB_CONTEXT
works:(notice the
DEBUG
log message)However trying to set log level for
org.springframework.web.context.ContextLoader
doesn't work:I've also tried with:
The issue is that
LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB_CONTEXT_CONTEXTLOADER
gets resolved toorg.springframework.web.context.contextloader
inLoggingApplicationListener#setLogLevels
which obviously won't configure the desired logger. I would assume there should be some special handling for setting concrete loggers. I didn't find anything in reference documentation about this limitation.The text was updated successfully, but these errors were encountered: