G
Guest
I've been having a problem writing to an event to the Application log. I
believe the issue is caused by the fact that the source was previously both a
custom log and the source.
I deleted the log using EventLog.Delete(logname);
I couldn't delete the source as it there was an error reporting that I
couldn't delete the event source as it had the same name as the log. Once I
deleted the log, the source appeared to not have any reference to it.
On my XP machine, I can successfully add events to the Application Log with
the same source as before. However, on a 2003 server in which I had done the
same, I cannot add that source to the Application. I can make up any other
custom source and successfully create en event in the Application log.
Code I used to create custom event:
String sourceName = "My Custom Source";
String logName = "Application";
String sEvent = "Sample Event";
EventLog log;
if (EventSourceTextBox.Text.Trim() != "")
{
if (!EventLog.SourceExists(sourceName))
EventLog.CreateEventSource(sourceName, logName);
log = new EventLog();
log.Source = sourceName;
log.WriteEntry(sEvent, EventLogEntryType.Error);
}
Does anyone have any suggestions? Thanks for any ideas.
believe the issue is caused by the fact that the source was previously both a
custom log and the source.
I deleted the log using EventLog.Delete(logname);
I couldn't delete the source as it there was an error reporting that I
couldn't delete the event source as it had the same name as the log. Once I
deleted the log, the source appeared to not have any reference to it.
On my XP machine, I can successfully add events to the Application Log with
the same source as before. However, on a 2003 server in which I had done the
same, I cannot add that source to the Application. I can make up any other
custom source and successfully create en event in the Application log.
Code I used to create custom event:
String sourceName = "My Custom Source";
String logName = "Application";
String sEvent = "Sample Event";
EventLog log;
if (EventSourceTextBox.Text.Trim() != "")
{
if (!EventLog.SourceExists(sourceName))
EventLog.CreateEventSource(sourceName, logName);
log = new EventLog();
log.Source = sourceName;
log.WriteEntry(sEvent, EventLogEntryType.Error);
}
Does anyone have any suggestions? Thanks for any ideas.