You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I remove all traces of the logging provider, it works.
The problem seems to be that LogManager.getLogger returns a null pointer because the Logger isn't known yet.
It might be better to use Logger.getLogger instead, because that method creates a named Logger if it does not exist yet.
I am not sure what you mean by "loading correctly"? I do have a Log4J configuration to filter what log level I see - that configuration is used and I can see that this is picked up for the System.Logger facade. I have no specific JUL configuration in use.
But my point is: The LogManager method you are using - by API definition - may return NULL and your code is not prepared for the case. Even if it may be possible to make a configuration that would prevent a null pointer being returned, a missing logging configuration should not lead to libraries not working.
Activity
Fix robaho#2 NPE when used with Log4J2-JPL
robaho commentedon Aug 29, 2024
It seems that the log4j provider is not mapping the system Logger instances to the utility logger instances - which is normally the case.
See this https://www.reddit.com/r/java/comments/14sco4r/slf4j_or_systemlogger/ - are you certain you are loading this correctly so the System logger is mapped properly?
taranion commentedon Aug 29, 2024
I am not sure what you mean by "loading correctly"? I do have a Log4J configuration to filter what log level I see - that configuration is used and I can see that this is picked up for the System.Logger facade. I have no specific JUL configuration in use.
My Log4J2 config is
But my point is: The LogManager method you are using - by API definition - may return NULL and your code is not prepared for the case. Even if it may be possible to make a configuration that would prevent a null pointer being returned, a missing logging configuration should not lead to libraries not working.
fix issue #2 to avoid NPE when log4j is used
robaho commentedon Aug 30, 2024
Your provided code changes were correct. Thank you for the PR. This is fixed in 1.0.8.