« TextBox.Lines property makes a deep copy on both set and get. | Main | MSDE, database distribution, osql command line tool. »

Simple EventLog entry writing

The following one-liner writes to the Application event log in both debug and release modes. The documentation does a great job of making it seem much more complicated…until you notice that half the overloads for WriteEntry are static:

 

EventLog.WriteEntry("Kizmet.Test", String.Format("This is a test."));

 

A “source” is an arbitrary string which will appear prominently in the event log’s event list view. A source can be registered which allows you to specify exactly which log you want to write to and is presumably a great idea for high volume logging. A source will automatically be registered with the Application log if it is used to write an event before being registered.

 

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)