Shaily,

log4net is deliberately catch exceptions because it guarantees not to
throw unexpected exceptions into the calling application due to
configuration issue.

Also there are times when log4net may be working asynchronously to the
calling application and therefore cannot throw an exception up the call
stack to the calling application.

log4net uses a plugin framework for error handling, each Appender has an
ErrorHandler property which holds an IErrorHandler object. This is used
to handle errors reported by the Appender. The default error handler
used is the OnlyOnceErrorHandler and this writes the first error only
(per appender) to the console.

If you want to handle errors in a custom way all you need to do is to
create your own implementation of the IErrorHandler interface and then
set the ErrorHandler property on the appenders to use this new type, for
example:

<appender ...>
  ...
  <errorHandler type="MyErrorHandler, MyAssembly" />
</appender>

Error handlers can only be set on appenders and there is no way of
globally overriding the default error handler for all appenders.

Nicko


> -----Original Message-----
> From: Shaily Goel [mailto:[EMAIL PROTECTED] 
> Sent: 14 September 2004 12:41
> To: [email protected]
> Cc: [EMAIL PROTECTED]
> Subject: Re: catching the exceptions thrown by log4net
> 
> just to add in: I do not want to do Console.SetOut () to 
> redirect the exceptions to a file....
> 
> I want to catch the exceptions which is thrown by log4net. Is 
> there a way by which i can catch he exceptions thrown by 
> log4net...as i found whenever the exception is raised log4net 
> itself is catching it and sending an error stream to standard console.
> 
> Is there a way i can avoid this thing...so that the 
> exceptions will be catched in my application which is calling 
> log4net functions internally
> 
> Please let me know this
> 
> Thanks
> Shaily
> 
> 
> >>> [EMAIL PROTECTED] 9/14/2004 10:48:00 AM >>>
> I am using log4net to log events (Error , Warning , Info and 
> Debug)to RollingFileAppender, Syslog etc..
> 
> Currently if any error or warning occurs during the working 
> of log4net it throws exceptions which it write to console as 
> log4net:Error <exception> or log4net.Warn <exception> 
> 
> My requirement is like this: Whenever any exception(Error , Warning or
> Info) is raised during the working of log4net . it should 
> write the exception in file instead of writing it to Console. 
> How can i achieve this. What should i do to catch the 
> exceptions which is thrown by log4net environment.
> 
> Environment:
> Suse 8.2
> Log4Net 120 Beta 8
> mono 
> 
> Thanks
> Shaily
> 
> 
> 
> 
> 

Reply via email to