Can't see Events in Event Viewer [Logging]

Topics: Logging Application Block
Jan 26, 2009 at 9:48 PM

I am trying to log some events in the windows event viewer. I tried the hands on lab and it logs the events perfectly. I can see the events from the EnoughPI project in the event viewer. But, when I try to do the same thing in a new project, I can't see any events in the Windows Event viewer. If I use a flat file listener instead, it works just fine. Here's my configuration:

<loggingconfiguration logwarningswhennocategoriesmatch="true" defaultcategory="General" tracingenabled="true" name="Logging Application Block"> <listeners> <add name="Formatted EventLog TraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" filter="All" traceoutputoptions="None" listenerdatatype="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" log="Application" formatter="Text Formatter" source="WindowsFormsApplication1"> </add> <formatters> <add name="Text Formatter" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp} Message: {message} Category: {category} Priority: {priority} EventId: {eventid} Severity: {severity} Title:{title} Machine: {machine} Application Domain: {appDomain} Process Id: {processId} Process Name: {processName} Win32 Thread Id: {win32ThreadId} Thread Name: {threadName} Extended Properties: {dictionary({key} - {value} )}"> </add> <categorysources> <add name="General" switchvalue="All"> <listeners> <add name="Formatted EventLog TraceListener"> </add> </listeners> </add> <specialsources> <allevents name="All Events" switchvalue="All"> <notprocessed name="Unprocessed Category" switchvalue="All"> <errors name="Logging Errors & Warnings" switchvalue="All"> <listeners> <add name="Formatted EventLog TraceListener"> </add> </listeners> </errors> </notprocessed> Here's what I do to log the event: LogEntry log = new LogEntry(); log.Message = string.Format("Calculated PI to {0} digits", 100); log.Categories.Add("General"); log.Priority = 2; </allevents></specialsources></categorysources> </formatters> </listeners> </loggingconfiguration>
Jan 27, 2009 at 1:10 AM
Do you have the same environment for both project? What's your environment?

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.