开发者

Logging errors on Windows 2003 Server using the EventLog class

开发者 https://www.devze.com 2022-12-13 15:55 出处:网络
I\'ve tried logging errors in my application, using the EventLog class.. But the Event Viewer on Windows 2003 Server is very limited as far as displaying the 开发者_开发百科stuff I log.

I've tried logging errors in my application, using the EventLog class.. But the Event Viewer on Windows 2003 Server is very limited as far as displaying the 开发者_开发百科stuff I log.

Here's what I'm doing:

if (!EventLog.SourceExists("TestApp.exe"))
{
    EventLog.CreateEventSource("TestApp.exe", "TestApp");
}

EventLog.WriteEntry("TestApp.exe", Exception.Message);

The entry shows up in the Event Viewer, but I can't seem to find the the exception-message anywhere in the interface.

Am I doing something wrong? Or is the Event Viewer in Windows 2003 Server just crap? Are there any alternatives, beyond dumping errors to a text-file?


Two options are Systems.Diagnostics and log4net

Both can be configured to log to the file system, database, emails, eventlog, console, etc...

Log4net is my preferred option as I usually use NHibernate for data access.


Event properties should include needed information. You just have to double click event in the Event Viewer on 2003.


I ended up logging errors to a text-file, since the Event Viewer in Windows 2003 is far too simple to display the data I want to log.

0

精彩评论

暂无评论...
验证码 换一张
取 消