Event source

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tshad

    Event source

    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.Sour ceExists(source , machine))
    EventLog.Create EventSource(sou rce, 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.Delete EventSource("Re pos")

    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


Working...