Event Viewer Logging - Add a new overall type

S

Steven Nagy

Hi,

I have Enterprise Library and am using the Logging Application block
successfully to log to the Event log.
Currently I can only put enteries into the existing event viewer types
(Application, Security, etc). Application is best for me currently.

But I would like to add a new overall type called "MyApplication" and
write logs to there instead so that they don't get mixed up with other
apps. On my PC, I have an overall type called "Internet Explorer"
which presumedly is for anything that happens in IE. Can I do the same
thing?

My app would need to be dynamic enough to check that my "MyApp" type
exists first, and if not, create it, and then write the log.

Any ideas?

Cheers,
Steven
 
M

Mr. Arnold

Steven Nagy said:
Hi,

I have Enterprise Library and am using the Logging Application block
successfully to log to the Event log.
Currently I can only put enteries into the existing event viewer types
(Application, Security, etc). Application is best for me currently.

But I would like to add a new overall type called "MyApplication" and
write logs to there instead so that they don't get mixed up with other
apps. On my PC, I have an overall type called "Internet Explorer"
which presumedly is for anything that happens in IE. Can I do the same
thing?

My app would need to be dynamic enough to check that my "MyApp" type
exists first, and if not, create it, and then write the log.


At the top of your program.

private System.Diagnostics.Eventlog eventlog1;

http://msdn2.microsoft.com/en-us/library/49dwckkz(VS.71).aspx

This is a VB example, but it's done the same way in C#.

If Not eventlog1.SourceExist("ThePhile.com") Then
eventlog1.CreateEventSource("ThePhile.com"), "My Application")
end if

Then you tie your app to the Eventlog.

eventlog1.source = "ThePhile.com";

So, you put it in a subroutine and execute it a program start.


You can find the eventlog in the registry and delete it, until you get your
naming right.
 
M

Maverick

Hi,

I have Enterprise Library and am using the Logging Application block
successfully to log to the Event log.
Currently I can only put enteries into the existing event viewer types
(Application, Security, etc). Application is best for me currently.

But I would like to add a new overall type called "MyApplication" and
write logs to there instead so that they don't get mixed up with other
apps. On my PC, I have an overall type called "Internet Explorer"
which presumedly is for anything that happens in IE. Can I do the same
thing?

My app would need to be dynamic enough to check that my "MyApp" type
exists first, and if not, create it, and then write the log.

Any ideas?

Cheers,
Steven

There is another way of doing this:
You can use EventLogInstaller class to install advanced configured
event log sources.

http://msdn2.microsoft.com/en-us/library/system.diagnostics.eventloginstaller.aspx

Good Luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top