logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominik Psenner" <dpsen...@gmail.com>
Subject AW: Dynamically change log levels confined to ThreadContext
Date Fri, 13 Feb 2015 07:16:13 GMT
Hi Christopher,

 

I believe that you would have to create your own level evaluator
implementation. Basically you implement the interface log4net.Filter.IFilter
or, to make the interaction with the filter chain less painful, you extend
log4net.Filter.FilterSkeleton. There you can override the method
Decice(LoggingEvent) and fit it to your needs. Last but not least you will
then configure log4net to set up your filter in the configuration and you
can do that just like one would reference a custom appender
(http://logging.apache.org/log4net/release/faq.html#custom-appender).

 

Best regards,

Dominik

 

Von: Christopher Landry [mailto:clandry@igloosoftware.com] 
Gesendet: Donnerstag, 12. Februar 2015 21:01
An: log4net-user@logging.apache.org
Betreff: Dynamically change log levels confined to ThreadContext

 

I have a web app, and I'm trying to allow users to set the logging level via
a query parameter. Got this working pretty easily.

 

The issue is that it doesn't just change the logging level for that request,
it's changed for all requests that come in during the life cycle of that
request - since I'm setting it back to the default level when the request is
resolved.

 

I have tried adding the following in my appender, but it's not working as I
hoped.

 

<evaluator type="log4net.spi.LevelEvaluator">

     <threshold>

           <layout type="log4net.Layout.RawPropertyLayout">

                <key value="LogLevel" />

     </threshold>

</evaluator>

 

And set a ThreadContext property called LogLevel to the appropriate level,
but that doesn't seem to work either.

 

Any thoughts? Have I missed something obvious?

 

Thanks!


Mime
View raw message