[slf4j-user] Question about throwing exception during initialization

Shawn Song mr.song.shawn at gmail.com
Tue May 11 13:41:28 CEST 2021


Hi,

I'm using slf4j with logback implementation. We have some critical system
properties that are used to configure logback and I want developers to
explicitly set them before they call `LoggerFactory.getLogger()`. I want to
throw an exception if the properties are not set. I have tried to throw the
exception from logback `StatusListener` but SLF4J catches all exceptions
during its initialization (in org.slf4j.impl.StaticLoggerBinder#init). I
know I can check the values of those properties at the start of the
application but because they are purely used to configure logback, so I
want to keep it inside the configuration code. Is there any way to stop
SLF4J from catching the exceptions?

Thanks
Shawn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-user/attachments/20210511/b0ce438e/attachment.html>


More information about the slf4j-user mailing list