I am developing a small app using C# on VS 2008 on XP.
I having trouble writing to a custom event log that I created. I can see that the log exists, and that my source is registered to the log:
myLogs = EventLog.GetEventLogs(myMachine);<br/>
Console.WriteLine("Number of logs on computer: " + myLogs.Length);<br/>
<br/>
for (int i = 0; i < myLogs.Length; i++)<br/>
Console.WriteLine("Log: " + myLogs.Log);<br/>
<br/>
Console.WriteLine("Source " + sourceName + " is registered to " + EventLog.LogNameFromSourceName(sourceName, myMachine));
However, when I try to write to the log, either using an instance or the static EventLog method, the message is always logged to the Application log, rather than my custom log, which I can see as listed as one of the logs under the Event Viewer.<br/>
EventLog myLog = new EventLog();<br/>
myLog.Source = sourceName;<br/>
myLog.WriteEntry(" writing to log " + logName + "; time is now " + DateTime.Now);<br/>
EventLog.WriteEntry(sourceName, " writing (again?) to log " + logName + "; time is now " + DateTime.Now);
Ive read many posts; I cut and pasted the samples from MSDN and the Visual Studio 2008 doc; but everything is getting written to the Application log, rather than my designated custom logs.
As you can tell, Im new to C#; hopefully there is a simple answer to this problem.
Any help would be greatly appreciated.
<br/>
View the full article
I having trouble writing to a custom event log that I created. I can see that the log exists, and that my source is registered to the log:
myLogs = EventLog.GetEventLogs(myMachine);<br/>
Console.WriteLine("Number of logs on computer: " + myLogs.Length);<br/>
<br/>
for (int i = 0; i < myLogs.Length; i++)<br/>
Console.WriteLine("Log: " + myLogs.Log);<br/>
<br/>
Console.WriteLine("Source " + sourceName + " is registered to " + EventLog.LogNameFromSourceName(sourceName, myMachine));
However, when I try to write to the log, either using an instance or the static EventLog method, the message is always logged to the Application log, rather than my custom log, which I can see as listed as one of the logs under the Event Viewer.<br/>
EventLog myLog = new EventLog();<br/>
myLog.Source = sourceName;<br/>
myLog.WriteEntry(" writing to log " + logName + "; time is now " + DateTime.Now);<br/>
EventLog.WriteEntry(sourceName, " writing (again?) to log " + logName + "; time is now " + DateTime.Now);
Ive read many posts; I cut and pasted the samples from MSDN and the Visual Studio 2008 doc; but everything is getting written to the Application log, rather than my designated custom logs.
As you can tell, Im new to C#; hopefully there is a simple answer to this problem.
Any help would be greatly appreciated.
<br/>
View the full article