LoggerContext initialization error results in NoSuchMethodError with SLF4j 2.0.10
ianprime0509 opened this issue · comments
As of SLF4j 2.0.10, the internal org.slf4j.helpers.Util.report
method is commented out: https://github.com/qos-ch/slf4j/blob/v_2.0.10/slf4j-api/src/main/java/org/slf4j/helpers/Util.java#L120-L124
Unfortunately, this method is being used in Logback to report errors initializing the LoggerContext: https://github.com/qos-ch/logback/blob/v_1.4.14/logback-classic/src/main/java/ch/qos/logback/classic/spi/LogbackServiceProvider.java#L49-L65
The result is that if the LoggerContext initialization fails for whatever reason (e.g. an exception thrown in some component's start
method), a NoSuchMethodError
is thrown and bubbles up to the caller, most likely causing the application using it to exit. In contrast, with SLF4j 2.0.9, an error message is printed including the stack trace of the root cause exception, and no exception is thrown to the caller, so the rest of the program can work as usual (except without logs).
In commit qos-ch/slf4j@c52da92 the change was reverted. Released in 2.0.12.
Now the method is still there, but deprecated and Reporter.error is recommended.
Now the TODO here is to upgrade dependency, and replace calls to the new methods.