writing to event log

G

Guest

Hi
Does any body know how to register my own eventlog source?
and how to register my own category and eventid for the eventlogentry?


TIA

--
 
P

Parag

Hi,
You need to create an object of System.Diagnostics.EventLog. This will enable you to create the event log and write to it.
The sample code in C# for it could be
System.Diagnostics.EventLog eventLog =

new System.Diagnostics.EventLog();

// Create the source if it does not already exist

if( !System.Diagnostics.EventLog.SourceExists(

this._EventLogSource) )

{

System.Diagnostics.EventLog.CreateEventSource(

this._EventLogSource, this._EventLogName);

}

// Code for writing to event log.

Regards,

Parag Kulkarni
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top