Error logging in C#

Lots of log4net advocates here so I’m sure this will be ignored, but I’ll add my own preference:

System.Diagnostics.Trace

This includes listeners that listen for your Trace() methods, and then write to a log file/output window/event log, ones in the framework that are included are DefaultTraceListener, TextWriterTraceListener and the EventLogTraceListener. It allows you to specify levels (Warning,Error,Info) and categories.

Trace class on MSDN
Writing to the Event Log in a Web Application
UdpTraceListener – write log4net compatible XML messages to a log viewer such as log2console

Leave a Comment