log to event viewer (but a ne section - not Application)

Topics: General discussion, Logging Application Block
Sep 16, 2010 at 3:18 PM

Hello ,

i am loging my application to evel viewer however i want to log it ti a diffarent section in event viewer that is called "MyApplication" etc..

now today i log it by setting the the config file (Trace Listeners node ---> in the properties pane i set the log as "Application") and in that way i log it to event viewer under "Application".

how can i set the entlib to log to a differant section in event viewer?

i tryed setting the log propertie to a differant name but didn"t work..

please any help will be more than helpful..


Sep 17, 2010 at 12:25 AM

What you're trying to do is create a new event log. You'll need to be an administrator to actually create the log; once it's set up, you also need to set up your event source (again, as administrator). Then it should just work. It's probably failing silently because either the log doesn't exist or the event source isn't registered.


Sep 19, 2010 at 7:32 AM

Hello ctavares thank you for your asistance , but can you guide me how can i register the event source?

i am adminstrator on my  machine (server) i created a new log on the event log i set up my xml config(entlib) with the propetie with the new name but again i am missing somthing..


Sep 20, 2010 at 4:22 AM

Here's the code using the EventLog API on how to register an event source to a given log:

System.Diagnostics.EventLog.CreateEventSource(eventSourceName, "MyApplication");

Another approach is running an elevated PowerShell process using this command:

[System.Diagnostics.EventLog]::CreateEventSource( sourceName, logName )

as suggested in this FAQ.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.