Open sjmuir opened 18 hours ago
@sjmuir The mdcAdapter
to loggerContext
is assigned when Logback is initialized by LogbackServiceProvider
.
Are you using a loggerContext
created in a unit test or are you initializing Logback on your own?
@ceki It's not a unit test, it's production code that we're trying to upgrade various libraries in, including logback.
This method is invoked by ch.qos.logback.classic.callAppenders(ILoggingEvent event). In my case, for this parameter:
event.toString() = "Logger[com.bluepumpkin.IU.FrameWork.FusionExchangeServer]" event.parent.toString() = "Logger[com.bluepumpkin.IU.FrameWork]" event.parent.parent.toString() = "Logger[com.bluepumpkin.IU]" event.parent.parent.parent.toString() = "Logger[com.bluepumpkin]" event.parent.parent.parent.parent.toString() = "Logger[com]" event.parent.parent.parent.parent.parent.toString() = "Logger[ROOT]" event.parent.parent.parent.parent.parent.parent = null
It's during the processing of "Logger[ROOT]" that the NullPointerException occurs.
@ceki Normally, the mdcAdapter
of loggerContext
is set at logback initialization time. The issue of unset mdcAdapter
is known to happen in case some component of your application initializes logback independently. This is not a logback issue but an issue of some other component of your application. Are you perhaps using an old version of spring-boot?
I checked this in versions 1.3.14 and 1.5.10. In ch.qos.logback.classic.spi.LoggingEvent.getMDCPropertyMap(), I found this line:
In some cases, I found that this returned null. This is not checked for, giving a NullPointerException on this line:
Please add a null pointer check.