How do I do logging in .Net ?

  • Thread starter Thread starter Guest
  • Start date Start date
Hi Yaron,

The following is one of the standard tool for logging in C#...

Log4net is a tool to help the programmer output log statements to a variety
of output targets. log4net is a port of the excellent log4j framework to the
..NET runtime.

Link: http://logging.apache.org/log4net/
 
The following code creates a Custom Log where you can write event to:

eventLog1 = new System.Diagnostics.EventLog();
if (!System.Diagnostics.EventLog.SourceExists("Transaction Service"))
{
System.Diagnostics.EventLog.CreateEventSource("Transaction Service",
"Transaction Log");
}
eventLog1.Source = "Transaction Service";


The following code actualy adds an event to the created log.

eventLog1.WriteEntry("MyWindowsService_CSharp Started",
EventLogEntryType.Information);
 
Back
Top