You set a level on a Logger not on an Appender. Here are some examples from Logback's XML configuration:
<logger name="com.foo.bar" level="INFO"/>
<logger name="com.foo.bas" level="WARN"/>
In these examples:
- Any Loggers belonging to the namespace:
com.foo.bar
will be subject to the INFO
level
- Any Loggers belonging to the namespace:
com.foo.bas
will be subject to the WARN
level
Logback's rootLogger
defines the default level, the following configuration tells Logback to apply the INFO
level to all loggers except for those loggers which are explicitly configured using a <logger/>
declaration:
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
More details in the docs.
To answer this specific question:
By logger itself i mean if i set the logger logging level to warning then logger won't pass levels less then warning (info,trace,debug) messages to appenders or is it the responsibility of appenders to drop message with level less then warning to destination?
If your Logger is created for a class in the namepsace: com.x.y
and you have defined a <logger name="com.x.y" level="INFO"/>
then the Logger will filter out any logger.debug()
invocations since the DEBUG
level is lower than the INFO
level.