Maybe OpenFile isn't the best place to look for error. If you want access to a 
logging event so you can send it somewhere else if writing to the appender 
fails you'll probably need to check that the previous write was successful 
higher up in the chain in one of the DoAppend methods. I'll keep thinking about 
this and try to write some code.



________________________________
 From: stalinsubash (Commented) (JIRA) <j...@apache.org>
To: log4net-dev@logging.apache.org 
Sent: Wednesday, April 18, 2012 6:59 AM
Subject: [jira] [Commented] (LOG4NET-332) I'm looking for the ability to set up 
a hierarchy of appenders, if a log to an ADONETAppender fails, log4net could 
then log to one of more "back-up" appenders
 

    [ 
https://issues.apache.org/jira/browse/LOG4NET-332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13256436#comment-13256436
 ] 

stalinsubash commented on LOG4NET-332:
--------------------------------------

Thanks Ron.

I successfully implemented Failover in ADONetAppender. If ADONet fails then it 
will rollover to FileAppender \ EventViewerAppender. Here I attached the 
ADONetAppender class file as well.

But I FileAppender I’ll fail, I can’t able to get Logging Event in FileAppender 
class. Here I’ll explain what scenario I tried. I tried to write a log in a 
text file but the path I mentioned in the configuration file was wrong, so 
while writing the log it will search the path to open the file in the method 
(OpenFile) in FileAppender class file, so in the try catch block I implemented 
below codes as well,

public override void OpenFile(string filename, bool append,Encoding encoding)
    {
        try
        {
                    m_stream = CreateStream(filename, append, FileShare.Read);
        }
catch (Exception ex)
                {
            LoggingEvent[] events = new LoggingEvent[0];
                    //events = (LoggingEvent[]);

string message = "FileAppender failed to find the path";
                    // Pass the logging event on to the attached appenders if 
there are any
                    if (iAppenderAttachedImpl != null)
                    {
                            iAppenderAttachedImpl.AppendLoopOnAppenders(events);
                    }
                    else
                    {
                            message += " and there is no appender-ref specified 
in the configuration for fail-over!";
                    }

                    ErrorHandler.Error(message, ex);
}
}

Could you please advise me on this ASAP?

Thanks
Stalin.M

                
> I'm looking for the ability to set up a hierarchy of appenders, if a log to 
> an ADONETAppender fails, log4net could then log to one of more "back-up" 
> appenders
> --------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4NET-332
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-332
>             Project: Log4net
>          Issue Type: New Feature
>          Components: Appenders
>    Affects Versions: 1.2.9
>         Environment: windows 7 , VS2010
>            Reporter: stalinsubash
>            Priority: Blocker
>              Labels: patch
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Basically, I'm looking for the ability to set up a hierarchy of appenders so 
> that if a log to an ADONETAppender fails, log4net could then log to one of 
> more "back-up" appenders, for example, a RollingLogFile or SMTP

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to