Home > Windows Server 2003, Windows Server 2008 > Creating a custom event log under Event Viewer to log server events

Creating a custom event log under Event Viewer to log server events

| More

By default, most applications write events to the Application Event Log.  This is a great central place to write logs to but sometimes you might have a requirement to log informational events from an application and you don’t want it filling up your Application Event Log because of the sheer number of informational events you might get a short period of time.  The solution is to create a custom event log for your application to hold these events.  You can then set max log size, overwrite rules, filters, etc. on this event log while your Application Event Log remains clean and intact.

The first step is to create the new log.  You have to do this in the registry.  Open up regedit and navigate to:

HKEY_LOCAL_MACHINESYSTEMControlSet001ServicesEventlog

Right click on the Eventlog key and click New > Key

Name this new key the same name you want your new event log to be named.  By default it will create the new .evt file here:

C:WINDOWSSystem32ConfigNew Key #1.evt

You can always rename it by editing the string value data in the registry if you like.

Now you need to add Sources to your new event log.  Right click in the right window pane under your new key and add a new Multi-String value called “Sources” and add the name of each of your applications on each line.  It should look something like this:

Now you need to move the association of your application from the Application event log to your new Custom log.  Just expand the “Application” key located at:

HKEY_LOCAL_MACHINESYSTEMControlSet001ServicesEventlogApplication

and copy whatever key you see in there for your app under your new Custom log:

HKEY_LOCAL_MACHINESYSTEMControlSet001ServicesEventlogCustomLog

There’s no copy/paste command so you can recreate the key if it’s small or you can export/import if it’s something complicated and you are afraid of mistyping something.  MAKE SURE to delete it from Application after you add it to the Custom log or it will not write events to your new log since Windows thinks its still associated with the Application log.  If it is a custom source, you need to create a DWORD value under this key with the value of 1:

You will also notice my custom app in this example is a .NET 2.0 appliaction so I want .NET to write the events to the log.  I have to create a string value called EventMessageFile and give it the path to the .NET 2.0 event log message dll:

C:WINDOWSMicrosoft.NETFrameworkv2.0.50727EventLogMessages.dll

Now you should reboot your server.  When it’s back up, check and see if your new event log appears under Event Viewer.  If your application is not writing events to your new log, test it manually by opening a command prompt and going to:

C:WINDOWSsystem32

and typing:

eventcreate /l CustomLog /t Information /so Application1 /id 1 /d “Test message”

You should get a message saying it was successfully written or you should get an error message with details on why it was not written.  If you followed the steps in this blog post, it should write the event just fine.

More of my posts you might like:

  1. Troubleshooting .NET 2.0 and WMI perfmon counters
  2. Changing the host header for an already existing Sharepoint site/application
| More
  1. AA
    February 22nd, 2010 at 11:31 | #1

    This worked wonderfully. I used my own custom log and created a test log with the event create statement. one change is that it did not needed source (/so) parameter.

  1. No trackbacks yet.
CommentLuv Enabled