Closed taranion closed 3 months ago
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?
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
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%5p [%15c] (%F:%L) - %m%n" />
</Console>
</Appenders>
<Loggers>
<Root level="DEBUG">
<AppenderRef ref="Console" />
</Root>
<Logger name="sun" level="ERROR"/>
<Logger name="com.sun" level="INFO"/>
<Logger name="xml" level="WARN"/>
<Logger name="jdk" level="warn"/>
<Logger name="java" level="INFO"/>
<Logger name="javafx" level="INFO"/>
<Logger name="telnet" level="WARN"/>
<Logger name="org.prelle.ansi" level="INFO"/>
<Logger name="de.rpgframework" level="INFO"/>
<Logger name="org.prelle.splittermond" level="WARN"/>
</Loggers>
</Configuration>
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.
Your provided code changes were correct. Thank you for the PR. This is fixed in 1.0.8.
When I start my server and the System.Logger LOG4J bridge (org.apache.logging.log4j:log4j-jpl:2.22.1) is loaded, I get the following NPE:
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.