Event source

T

tshad

I am trying change the log that my application writes to from Application to
a new log. But since I already have started writing to the Application
log - I get the error:

The source 'Repos' is not registered in log 'Repos'. (It is registered in
log 'Application'.) " The Source and Log properties must be matched, or you
may set Log to the empty string, and it will automatically be matched to the
Source

My code is doing:

string source;
string log;
string eventMessage;
string machine;

source = "Repos";
log = "Repos";
eventMessage = message;
machine = ".";

if (!EventLog.SourceExists(source, machine))
EventLog.CreateEventSource(source, log, machine);

EventLog eLog = new EventLog(log, machine, source);
eLog.WriteEntry(eventMessage, eventType);

I should be able to fix it by removing the source by:

EventLog.DeleteEventSource("Repos")

But how to I determine what log the source is registered to?

I can tell if the Source exists, but how do I tell what it is registered to?

Thanks,

Tom
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top