[slf4j-user] Determining whether a logger has been loaded

Steve Ramage sjr at sjrx.net
Thu Jul 3 03:18:19 CEST 2014


I'm not sure if this is an slf4j or a logback question. I have a library that would like to configure logging :) , but only in a way that is optional for users to use when making stand alone applications. Managing separate logback.xml files is tedious and many of the users of the library don't want to be bothered with this. Instead I interface, LoggingOption that they can use with JCommander (a command line parser), they then set this up however is appropriate (ConsoleOnlyLoggingOptions), (ComplexLoggingOptions), (SingleFileLoggingOptions), each one of these exposes command line arguments that are set as system properties to custom logback.xml files. It's expected that if the user overrides the logback.xml file that these options have no effect and that is okay.

 

When everything is ready, the users call LoggingOptions.initializeLogging() and the system properties are set and the first Logger is retrieved. The problem I have is occasionally a sneak logger has been constructed before hand. I am looking for a portable (logback agnostic way), to detect this condition. I don't control the main() methods or anything. Is there something I can access in the SLF4J API that would tell me a logger has already been retrieved? I don't need to do anything but print a friendly warning.

 

Thanks,

 

Steve Ramage

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-user/attachments/20140702/13097c7c/attachment.html>


More information about the slf4j-user mailing list