Saturday, February 04, 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: Log not logging in custom filter
Prev Next
You are not authorized to post a reply.

Author Messages
stefan.moser

05/19/2009 11:09 PM  


I'm writing a custom filter (inherits from FilterSkeleton) and I want to log
errors inside the filter.  The problem is that any log events created inside
the filter is not getting logged.  Is there a special restriction that log
events cannot be created this far down inside the loggin pipeline?

public override FilterDecision Decide(LoggingEvent loggingEvent)
{
    // Do the interesting stuff

    // In some exceptional case, log an error
    LogManager.GetLogger("TheLogger").Error("log message", exception);
}

Any reason why this code wouldn't work?
--
View this message in context: http://www.nabble.com/Log-not-logging-in-custom-filter-tp23624032p23624032.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Loren Keagle

05/19/2009 11:59 PM  

stefan.moser wrote:
> I'm writing a custom filter (inherits from FilterSkeleton) and I want to log
> errors inside the filter.  The problem is that any log events created inside
> the filter is not getting logged.  Is there a special restriction that log
> events cannot be created this far down inside the loggin pipeline?
>
> public override FilterDecision Decide(LoggingEvent loggingEvent)
> {
>     // Do the interesting stuff
>
>     // In some exceptional case, log an error
>     LogManager.GetLogger("TheLogger").Error("log message", exception);
> }
>
> Any reason why this code wouldn't work?
>  

Inside of the log4net framework, there is an internal logger called
LogLog.  It's used throughout the appender framework, but I imagine
there's no problem using it in a filter.

Just call:

LogLog.Error("log message");


~Loren

stefan.moser

05/20/2009 12:13 AM  


Thanks Loren, that's exactly what I'm looking for.

Cheers,
Stefan

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Log not logging in custom filter



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