[slf4j-user] How to programmatically set log level in SLF4J?

Ceki Gülcü listid at qos.ch
Fri Mar 16 20:31:09 CET 2007


At 06:33 AM 3/15/2007, wolverine my wrote:
>Yes, I agreed that programatically setting the log properties is not a
>common practise.
>
>The customer wants to maintain (or bother) only one single application
>configuration file.
>
>In order to isolate log4j.properties from the customer, we will have
>to read the log level from the current configuration file and set it
>into our Log4j logger.
>
>Well, if that is the case... it would be better if we use Log4j
>directly without using SLF4J?


Configuration is only a small part of the picture. If you use log4j
directly, then your dependency on log4j will be at the source code
level. Instead if you code against SLF4J, you can switch logging
systems much more easily. You only have to worry about migrating few
configuration instructions, but not your whole source code.

Logback, log4j's successor, natively implements the SLF4J API. This
means that if logback is your logging system of choice you have to use
SLF4J. By the same token, once you start using SLF4J, it becomes
trivially easy to switch to logback as your underlying logging system.

HTH,


-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch




More information about the slf4j-user mailing list