I am trying to configure basic logging for Windows.net through the event log System.Diagnostics.EventLog, but I fail to see any events that are actually logged. Consider the following code:
private static readonly string EventLogName = "LogName";
private static readonly string EventLogSource = "AppName";
if (!EventLog.Exists(EventLogName))
{
EventLog.CreateEventSource(EventLogSource, EventLogName);
return;
}
else
{
Trace.TraceInformation("Attempting log");
EventLog.WriteEntry(EventLogSource,
"StaticWriteEntry",
EventLogEntryType.Error);
using (var log = new EventLog())
{
log.Log = EventLogName;
log.Source = EventLogSource;
log.WriteEntry("WriteEntry?", EventLogEntryType.Error);
}
}
return;
The first time I create a log and exit the application, modeled on MSDN. Of course, this log creation will ultimately go into customization. Subsequent runs attempt to write a message to the generated event log.
No exceptions are thrown. The log was created successfully (I can open it in the Windows Event Viewer). Nothing relevant is logged in the security log.
WriteEntry(). - . Server2008 UAC. ( , .) ?
( , EventLogTraceListener app.config, -, .)