kamagra bombone novi sad

Wednesday, August 24, 2016

Add an entry to event log in C#

October 31, 2009 by · 2 Comments 

EventLog is a good place to write your applications log. Here is an example to show how to do this:

If ( !EventLog.SourceExists("TestCategory"))


EventLog evtLog = new EventLog();

evtLog.Source = "TestCategory";

evtLog.WriteEntry("This is a test log.",EventLogEntryType.Information);

First of all there is a check if the category exists. If not it will be created. Then we create an object of the type EventLog. we set the given category. After that you can use the method WriteEntry to write a new entry to the eventlog.

if you want to use this with ASP.NET you have to do some additional steps. There is a registry key where the ASPNET-User or the user of the application pool must have the necessary permissions:


We have to set the following permissions:

  • Query Value
  • Set Value
  • Create Subkey
  • Read Subkey
  • Notifications
  • Read

After setting these permissions it should be possible to create eventlog enteries through ASP.NET

Top Blogs


2 Responses to “Add an entry to event log in C#”
  1. SoloTeens says:

    Thanks for this great post! I’m new reader of your blog 😉

  2. blogg.no says:

    realy good information

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!