Appenders that extend AppenderSkeleton have an ErrorHandler property that is 
trigged when an error occurs. I modified the default error handler, 
OnlyOnceErrorHandler, to add public properties for Message, Exception, and 
ErrorCode. I don't think they belong on the IErrorHandler interface because not 
all IErrorHandler implementations necessarily care about the last time the 
Error methods were called. I also modified OnlyOnceErrorHandler to report the 
ErrorCode.

You could write this in your application start up code:

OnlyOnceErrorHandler errorHandler = 
 (OnlyOnceErrorHandler)rollingFileAppender.ErrorHandler;

throw new LogException(String.Format("Unable to configure RollingFileAppender 
[{0}]. ErrorCode: [{1}]. Message: [{2}]",
 rollingFileAppender.Name, // 0
 errorHandler.ErrorCode, // 1
 errorHandler.Message), errorHandler.Exception);  // 2

I'll make an issue and upload the patch when Jira its back on-line.

Another improvement may be to allow a default IErrorHandler to be set at the 
repository level so all appenders automatically use that instead of 
OnlyOnceErrorHandler. Add it to Hierarchy instead of LoggerRepositorySkeleton?

----- Original Message ----

From: Bill Schmidt <[EMAIL PROTECTED]>

To: log4net-user@logging.apache.org

Sent: Thursday, September 28, 2006 3:30:21 PM

Subject: Retrieving log4net error conditions



Hello list,

   I am wondering if there is a way to recieve an error messages from log4net 
1.2.10 if it is unable to write to a log file.  Reading through the release faq 
( http://logging.apache.org/log4net/release/faq.html) I see that exceptions 
should not be thrown, however is there some method I can call to see what the 
last error(if any) log4net encountered when writing to the log.

 

To be more specific, I am using a RollingFileAppender with C# to log for my 
application.   If the appender is configured to log to a drive that is full or 
not present, is there a way after I write a message to see if the write was 
successful so that if there was a problem I can notify the user in some way. 



ie:

log.ERROR("my error message");

success = log.getsuccess();







thank you

  -Bill

 







Reply via email to