Friday, May 18, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: bypassing the IsEnabledFor check
Prev Next
You are not authorized to post a reply.

Author Messages
Chris Jerdonek

05/23/2008 7:27 AM  

Hi, I've got a question.

I'm currently wrapping the LogManager class and the resulting ILog to
gain some custom behavior.

I would like to be able to flag certain logging events as "important" by
providing overloads of the Debug/Info/etc methods.  The important events
would then get logged -- regardless of the configured level of the
logger.  Do you have any advice on how to do this?  This would be
possible, for example, if ILogger contained a "ForceLog" method (as
what's contained in Logger), but it doesn't.

One possibility would be to set a property on these special events, and
then use a PropertyFilter to detect the flag.  But if I understand the
precedence of how filters work, this would require setting my root
logger level all the way down and then losing the ability to use the
"Is...Enabled" properties.  I'd like to preserve that ability because
I'm doing some (relatively) expensive things prior to logging each
event.

Another possibility is to designate a node in the logger hierarchy for
such calls, but that would artificially divide the existing hierarchy:
the "important" events span all parts of the current hierarchy, and I'd
like to preserve the same hierarchical relationship of the important
events with the non-important events.

A third idea may be to store the true log level in a second place as a
property, and then to log %property{level} instead of %level, for
example.  But that seems prone to error down the road.

Any other ideas?  Getting at the ForceLog method seems like it might
require a lot of reimplementation.

Okay, thanks,
--Chris




You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > bypassing the IsEnabledFor check



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement