I use slf4j 1.7.2 with logback 1.0.7. I want to be able to supply a command line parameter to my Java application that sets the level of messages logged to stdout. For example, -logLevel trace
should result in all messages logged but -logLevel warning
only in warnings and errors. The logs should come from all loggers in the application (= the root logger).
Currently I have a ConsoleAppender
for System.out
that ensures, by means of TresholdFilter
, that only info
warning
and error
messages are printed out to stdout. The root logger references it. I don't know how to programatically change the filtered levels for this appender, which I need to base the logged levels on a command line parameter.
While the levels logged to stdout should be influenced, I still want for the root logger to log all levels, as they are sent to other appenders, e.g. diagnostics.txt
file that should have all the levels all the time.
Cheers!
Konrad