Reputation: 1634
In simplelogger.properties file we can set default logging level as
org.slf4j.simpleLogger.defaultLogLevel=error
but If one wants to set logging level for specific package then how to do that? For example If the package name is
com.xxx.yyy
then If I put it in simplelogger.properties as
com.xxx.yyy.level=error
then it does not work. How to configure it?
Upvotes: 8
Views: 11721
Reputation:
The SLF4J SimpleLogger has all its documentation in its Javadoc.
As it says,
org.slf4j.simpleLogger.log.a.b.c
- Logging detail level for a SimpleLogger instance named "a.b.c". Right-side value must be one of "trace", "debug", "info", "warn", "error" or "off". When a SimpleLogger named "a.b.c" is initialized, its level is assigned from this property. If unspecified, the level of nearest parent logger will be used, and if none is set, then the value specified byorg.slf4j.simpleLogger.defaultLogLevel
will be used.
So you need to include a line like this in your simplelogger.properties:
org.slf4j.simpleLogger.log.com.xxx.yyy=error
If you start needing a more complex logging system than the SLF4J SimpleLogger, then you probably want to switch to using something like Log4j or Logback.
Upvotes: 18
Reputation: 58774
For setting level on your own package use different file per logging implementation
Configure SLF4J working with Java Logger
configure JDK logging either by editing JRE_DIRECTORY/lib/logging.properties
Configure SLF4J working with Log4J
add a configuration file such as src/main/resources/log4j.properties.
Configure SLF4J working with Logback
add a configuration file such as src/main/resources/logback.xml
Upvotes: 0