Why a Logging Framework Should Not Log
I always found SLF4J&#x27;s reasoning quite simple and logical and not at all an example of &quot;those situations which show that software is difficult, and that often there are only compromises&quot;.<p>I think the core problem in this case is that the author is not clear if they are writing a library or a (command line) application.<p>The following workflow has always worked well for me:<p>1) Do you expect users of your project to use it by putting it in their classpath and calling its methods from their code? Then it&#x27;s a library. You have no idea what else will be on the classpath and which context your library will be loaded in. (In fact, the user might not even be aware they are using your library thanks to transitive dependencies)<p>Libraries should never (if they can avoid it in any way) modify application-wide settings. So: Don&#x27;t include any logger implementation at all, <i>especially</i> not the nop logger. (Please. Seriously. I&#x27;ve had to deal with misbehaving libraries in that regard and finding out why your logger settings are suddenly overwritten is a serious PITA.)<p>2) Do you expect your project to be used as a command line&#x2F;standalone utility via java -jar ... or java -cp ...? Then you&#x27;re writing an application. <i>Do</i> include a logger implementation and all necessary configuration. You can do it safely here as no one else should be using your project as a dependency.<p>3) Your project is a mix of 1) and 2) : Find out which parts of your project are library and which are application and split into sub-projects accordingly.<p>There are a few special cases I see, but not many:<p>4) You&#x27;re writing unit tests for a library project: Do include a logger implementation, but make sure it&#x27;s only visible to the test system. E.g., in Maven, you would add the logger implementation as a test-scoped dependency and put all configuration in src&#x2F;test&#x2F;resources.<p>5) You&#x27;re writing a plugin&#x2F;servlet&#x2F;etc: Read up on your host system and find out if they provide logging or if it&#x27;s your responsibillity. Proceed accordingly.<p>6) You&#x27;re not using SLF4J but one of your dependencies does and so you get that message: Think about using SLF4J in your own project. Really. It&#x27;s becoming almost a standard and usually you can keep using your old logging framework below it - but it will make things much easier later on. But if you don&#x27;t want to, for some reason...
 6a) If you&#x27;re writing a library: Don&#x27;t do anything at all. Do not include any logger implementation. See 1). The user of your library will be in a much better position to deal with the problem than you are.
 6b) If you&#x27;re writing an application: Include the slf4j-xxx implementation that corresponds to your logging framework: The log events from your dependency will be routed to the logging framework you&#x27;re using and you can continue like you did before. If you&#x27;re very certain you don&#x27;t want <i>any</i> logging from <i>any library using SLF4J</i>, use the nop logger - however that is a very unusual case and a very inflexible solution.