This is a case where the name it is very close to the essence: the SLF4J SimpleLogger is actually a very simple logger. Still, it could be useful to spend some time exploring it in some detail.
There is something even simpler than SimpleLogger. If we don't want to have any log at all, we can use NOPLogger, implemented in the slf4j-nop-1.6.4.jar library (version number may vary). As its name suggests, each logging method in this class is implemented as a no-op. We can call them till we get blue in the face, still we won't generate anything.
Compared to it, SimpleLogger is not that extreme. To make it available to the project, we place slf4j-simple-1.6.4.jar in the specific Java Build Path. It probably makes sense using it only in very simple projects or some testing, as a temporary replacement for a real logger.
There is no way of configuring a SimpleLogger, we have to use it as it is:
- Only info, warn, and error message are generated;
- trace and debug methods are no-ops;
- the log message format is immutable;
- the log destination stream is System.err.
[Update: Since version 1.6.6, SLF4J SimpleLogger has gained more functionality. Please refer to the post written for the (currently) latest version, 1.7.5]
1.7.2 lets you set the log level: http://www.slf4j.org/apidocs/org/slf4j/impl/SimpleLogger.html
ReplyDeleteHi Peter, thank you for the update. I should review the slf4j posts to keep track of the 1.7 improvements.
Delete