Tim Huffam

Dotting the I and crossing the T of I.T.

  Home  |   Contact  |   Syndication    |   Login
  152 Posts | 0 Stories | 2310 Comments | 653 Trackbacks

News

Archives

Post Categories

Interesting Blogs/Links

Log4Net

This is something I wanted to do as a quick work around (rather than writing my own log4net appender) to being able to write SuccessAudit and FailureAudit events to the event log (something which log4net does not support out the box). Here's the method I used: private static ILog _Log = LogManager.GetLogger(Method... static log4net.Appender.EventLogAp... _eventLogAppender = null; // This only works if you have an EventLogAppender configured.public static...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

I found that there were a couple of things required to get this working - over and above the samples shown here. To initialize Log4Net and to tell it to load it's configuration from the web.config file add the following line to the Application_Start method within Global.aspx: log4net.Config.XmlConfigura... To make sure all unhandled exceptions are logged add the following line to the Application_Error method within Global.aspx: Log.Fatal("An uncaught exception occurred", this.Server.GetLastError())...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati