Formatted EventLog TraceListener fails silently EL 4.1 Logging WinXP VS2008

Topics: Logging Application Block
Aug 19, 2010 at 6:02 AM

Flat or Rolling file listeners work fine - ie they write to the file I've spec in the config...

however as I understand it the event log should be getting the errors and warnings under "Application" but there is nothing..., I'm guessing that there is either something missing config wise or something to do with permissions for the web app that is running... logging works to the text files fine, either when running the website (web.config) or the test (app.config).

Does anyone have suggestions on (a) how to fix and, more importantly, (b) how to troubleshoot this kind of issue...!!?!?

Thanks...

Here are the logging config info for both test and web config... in the (highly  possible) case that I'm doing something obviously stupid...

 

(web)

<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">

<logFilters>

<add name="Category" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging" categoryFilterMode="AllowAllExceptDenied">

<categoryFilters>

<add name="UI Events"/>

<!--<add name="Data Access Events" />-->

</categoryFilters>

</add>

<add name="Priority" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging" minimumPriority="2"/>

<add name="LogEnabled Filter" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging" enabled="true"/>

</logFilters>

<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.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Formatted EventLog TraceListener"/>

<add name="Rolling Flat File Trace Listener" rollFileExistsBehavior="Increment" rollInterval="Day" rollSizeKB="1000" timeStampPattern="yyyy-MM-dd" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="c:\logfiles\PCSMAT\trace.log" header="" footer="" traceOutputOptions="None" filter="All" formatter="Text Formatter"/>

</listeners>

<formatters>

<add template="{timestamp(local:yyyy-MM-dd HH:mm:ss.fff)} | {message} | {category} | P:{priority} | E:{eventid} | S:{severity} | T:{title} | M:{machine} | AD:{appDomain} | PID:{processId} | PNM:{processName} | TID:{win32ThreadId} | TNM:{threadName} | DICT:{dictionary({key} - {value})}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Text Formatter"/>

</formatters>

<categorySources>

<add switchValue="All" name="General">

<listeners>

<add name="Formatted EventLog TraceListener"/>

</listeners>

</add>

<add name="Trace" switchValue="All">

<listeners>

<add name="Rolling Flat File Trace Listener"/>

</listeners>

</add>

</categorySources>

<specialSources>

<allEvents switchValue="All" name="All Events"/>

<notProcessed switchValue="All" name="Unprocessed Category"/>

<errors switchValue="All" name="Logging Errors &amp; Warnings">

<listeners>

<add name="Formatted EventLog TraceListener"/>

</listeners>

</errors>

</specialSources>

</loggingConfiguration>

 

(test)

<loggingConfiguration name="Logging Application Block" tracingEnabled="true"

defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">

<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.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="Formatted EventLog TraceListener" />

<add fileName="c:\logfiles\PCSMAT\traceTEST.log" footer="" formatter="Text Formatter"

header="" rollFileExistsBehavior="Increment" rollInterval="Day"

rollSizeKB="1000" timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="Rolling Flat File Trace Listener" />

<add fileName="rolling.log" footer="----------------------------------------"

formatter="TraceFormatter" header="----------------------------------------"

rollFileExistsBehavior="Overwrite" rollInterval="None" rollSizeKB="0"

timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="TraceListenerRolling" />

</listeners>

<formatters>

<add template="{timestamp(local:yyyy-MM-dd HH:mm:ss.fff)} | {message} | {category} | P:{priority} | E:{eventid} | S:{severity} | T:{title} | M:{machine} | AD:{appDomain} | PID:{processId} | PNM:{processName} | TID:{win32ThreadId} | TNM:{threadName} | DICT:{dictionary({key} - {value})}"

type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="Text Formatter" />

<add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}"

type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="TraceFormatter" />

</formatters>

<logFilters>

<add categoryFilterMode="AllowAllExceptDenied" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="Category">

<categoryFilters>

<add name="UI Events" />

</categoryFilters>

</add>

<add minimumPriority="2" maximumPriority="2147483647" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="Priority" />

<add enabled="true" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

name="LogEnabled Filter" />

</logFilters>

<categorySources>

<add switchValue="All" name="Tracer">

<listeners>

<add name="TraceListenerRolling" />

</listeners>

</add>

<add switchValue="All" name="General">

<listeners>

<add name="Formatted EventLog TraceListener" />

</listeners>

</add>

<add switchValue="All" name="Trace">

<listeners>

<add name="Rolling Flat File Trace Listener" />

</listeners>

</add>

</categorySources>

<specialSources>

<allEvents switchValue="All" name="All Events" />

<notProcessed switchValue="All" name="Unprocessed Category" />

<errors switchValue="All" name="Logging Errors &amp; Warnings">

<listeners>

<add name="Formatted EventLog TraceListener" />

</listeners>

</errors>

</specialSources>

</loggingConfiguration>

Aug 19, 2010 at 7:23 AM

Is what you mean by "understand it the event log should be getting the errors and warnings under "Application" but there is nothing" is that you are expecting that when an error encountered in your application it will be automaticaly logged in the event log?  If yes, then this is not the case with LAB, the Logging Errors & Warnings special source receives log entries for errors and warnings that occur during the logging process and not the error encountered in the application.

While if this is not the case, I suspect what are you probably missing here is that the event source that you're using are not yet registered in your environment. Event sources must be registered with the operating system before you can successfully log using them. Normally the .NET framework will automatically create event sources the first time you use them, but creating event sources require administrator privileges. As such, any applications without admin rights (like almost all web applications) cannot create the event source and logging fails. Please see this FAQ item and see if it may help you with your problem http://entlib.codeplex.com/wikipage?title=Why%20are%20messages%20not%20logged%3f&referringTitle=EntLib%20FAQ.

Gino Terrado
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

 

Aug 22, 2010 at 7:54 PM

I think smerlon was having the same initial issue that I had, which is not to run the component using logging (for example, the LoggingExample program from the code samples) with admin privileges for the first time.

I too could not find any event log messages and AvanadeSupport's post jogged my memory on the need to run this with admin privileges for the first time.

It would be nice to have some report of this in case one forgets, but the EntLib does so much - who can possibly complain.

Thanks Microsoft for making this available. A great job!