|
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); } } |
- log4net exception handling Ramaa Davanagere
- Re: log4net exception handling Matthew Brown
- RE: log4net exception handling Ramaa Davanagere
- Re: log4net exception handling Matthew Brown
- RE: log4net exception handling Marc Lewandowski
- RE: log4net exception handling Nicko Cadell
- RE: log4net exception handling Ramaa Davanagere
