logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Brown <octav...@gmail.com>
Subject Re: log4net exception handling
Date Mon, 12 Dec 2005 19:18:38 GMT
I would write a second app that polls the log file every X seconds to see if
it's locked or if some other "bad" situation has occured.

On 12/12/05, Ramaa Davanagere <RDAVANAG@mobius.com> wrote:
>
>
>
> Well, I have a special situation and I'm not sure how to handle it...
>
>
>
> I have lot of components using log4net for tracing, logging, etc and they
> all use a single file for logging.  If for some reason, if a component
> hangs, the logfile is locked and there after nothing is logged into the log
> file.  In this scenario, I need to notify the administrator that logging has
> stopped because of the File Lock problem so that he can take action. How do
> I solve this problem?
>
>
>
> Bottom line, I need to notify the administrator if the logging has stopped
> working.
>
>
>
> -----Original Message-----
> *From:* Matthew Brown [mailto:octavius@gmail.com]
> *Sent:* Monday, December 12, 2005 11:21 AM
> *To:* Log4NET User
> *Subject:* Re: log4net exception handling
>
>
>
> For most people, it's far more annoying for the application to fail
> because of a logging error than because of a true application error:
>
> http://logging.apache.org/log4net/release/faq.html#reliability
>
> Is log4net a reliable logging system?
>
> No. log4net is not reliable. It is a best-effort and fail-stop logging
> system.
>
> By fail-stop, we mean that log4net will not throw unexpected exceptions at
> run-time potentially causing your application to crash. If for any reason,
> log4net throws an uncaught exception (except for ArgumentException and
> ArgumentNullException which may be thrown), please send an email to the
> log4net-user@logging.apache.org mailing list. Uncaught exceptions are
> handled as serious bugs requiring immediate attention.
>
> Moreover, log4net will not revert to System.Console.Out or
> System.Console.Error when its designated output stream is not opened, is
> not writable or becomes full. This avoids corrupting an otherwise working
> program by flooding the user's terminal because logging fails. However,
> log4net will output a single message to System.Console.Error and
> System.Diagnostics.Trace indicating that logging can not be performed.
>
>
>
> On 12/12/05, Ramaa Davanagere <RDAVANAG@mobius.com> wrote:
> >
> >
> >
> > Following is the method that logs messages to the log file.  Logger is
> > initiliazed correctly before calling this method.  If there is any error
> in
> > LogMessage() method, errors are logged to application event log. What I
> > don't understand is, if the log file that is used for logging messages
> is
> > currently locked, an exception is not raised in the code below. The code
> > continues to work as if it logged the messages to the log file. Why
> doesn't
> > the code jump to exception handling, if log4net is not able to log
> message.
> > How can I force it to jump to exception handling, if there is any
> problem
> > with log4net?
> >
> >
> >
> > public void LogMessage(string sMessage, int nLoggingLevel)
> >
> > {
> >
> >       try
> >
> >       {
> >
> >             switch((eLogging_Level) nLoggingLevel)
> >
> >             {
> >
> >                   case eLogging_Level.eInfo:
> >
> >                         logger.Info(StripSecureData(sMessage));
> >
> >                         break;
> >
> >                   case eLogging_Level.eError:
> >
> >                         logger.Error(sMessage);
> >
> >                         break;
> >
> >                   case eLogging_Level.eDebug:
> >
> >                         logger.Debug(StripSecureData(sMessage));
> >
> >                         break;
> >
> >                   case eLogging_Level.eWarning:
> >
> >                         logger.Warn(sMessage);
> >
> >                         break;
> >
> >                   case eLogging_Level.eFatal:
> >
> >                         logger.Fatal(sMessage);
> >
> >                         break;
> >
> >                   default:
> >
> >                         //do stuff here;
> >
> >                         break;
> >
> >             }
> >
> >       }
> >
> >       catch(Exception ex)
> >
> >       {
> >
> >             EventLog.WriteEntry("ErrorHandler","Error in " +
> > System.Reflection.MethodBase.GetCurrentMethod() + ": " +
> > ex.Message, EventLogEntryType.Error);
> >
> >       }
> >
> > }
>

Mime
View raw message