Doesn't write an EventLog

Topics: Logging Application Block
Jun 12, 2008 at 1:51 PM
Hi,

I use the Enterprise Library first time and I want to log messages with the EventLog Listener. If I use the FlatFile TraceListener, the messages were logged, but if I use the EventLog Listener I cannot find messages in Windows EventLog.

My sources:
<listeners>
      <add source="Enterprise Library Logging" formatter="Text Formatter"
        log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Formatted EventLog TraceListener" />
</listeners>

-----------------------------------

LogEntry logEntry = new LogEntry();
logEntry.EventId = 123456;
logEntry.Severity = TraceEventType.Error;
logEntry.Priority = 2;
logEntry.Message = "Informational message";
logEntry.Categories.Add("Trace");
logEntry.Categories.Add("UI Events");

Logger.Write(logEntry);

---------------------------------

What's wrong?
Jun 13, 2008 at 12:45 PM
Edited Jun 13, 2008 at 1:09 PM


timemaster wrote:
Hi,

I use the Enterprise Library first time and I want to log messages with the EventLog Listener. If I use the FlatFile TraceListener, the messages were logged, but if I use the EventLog Listener I cannot find messages in Windows EventLog.
What's wrong?
Hello

I am having a similar problem, although I got a bit further :-)

I found that if your code for some reason does not have permission to access the event log, the LAB will not log anything, not even an error. To see your events, you have to install your event log.
Go and read this post about installing event logs:
http://blogs.msdn.com/ploeh/archive/2007/09/20/InstallingEventSourcesForTheLoggingApplicationBlock.aspx

And then, if you are trying to log from an ASP.NET web site and get the same error as me, go check if someone has answered my question: http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=29602

Regards,
Joon