[slf4j-user] Muting a Logger

mspetrovic at gmail.com mspetrovic at gmail.com
Fri Feb 22 14:43:51 CET 2013


One way would be to use filters, assuming you have access to the information required decide to output to the appender in that filter.  And the mapped diagnostic context (MDC) could provide that information if you have no easier way.


On Feb 22, 2013, at 5:01 AM, Randall Wood <randall.h.wood at alexandriasoftware.com> wrote:

> I have a program that I am converting from Log4J to SLF4J, and have some logic paths that, in a couple of situations, mute output from a single Logger in a method, and then restoring the Logger to the user-selected logging level at the end of the method.
> 
> Is there any way to temporarily disable output from a single Logger in SLF4J?
> 
> Currently I am getting around this by setting a flag in the class to disable logging, and wrapping every logging statement in the affected methods with an if statement testing that flag, but would prefer some other method if one is available.
> 
> Randall Wood
> Alexandria Software
> 202.683.8604
> randall.h.wood at alexandriasoftware.com
> http://www.alexandriasoftware.com
> 
> _______________________________________________
> slf4j-user mailing list
> slf4j-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/slf4j-user


More information about the slf4j-user mailing list