Logging Application Block stopped writting to application event log

Topics: Logging Application Block
Dec 11, 2007 at 3:15 PM
I am using the Logging Application Block from EntLib 3.1 (May 2007) to write events to the Application event log from my application. My app is an aspx page deployed in a folder inside a MOSS site (.../wss/VirtualDirectories/80/MyApp). The logging configuration section was added to the web.config file in the 80 folder. This is my logging configuration section:

<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<add source="Transaction Wizard" formatter="Text Formatter"
log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Formatted EventLog TraceListener" />
<add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Text Formatter" />
<add switchValue="All" name="Transaction Wizard">
<add name="Formatted EventLog TraceListener" />
<add switchValue="All" name="General">
<add name="Formatted EventLog TraceListener" />
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<add name="Formatted EventLog TraceListener" />

The logging block has been behaving weird. At the beggining it started working fine and I was being able to see all my events in the application log. Suddenly it stopped logging events. I was able to get it back logging using different tricks, first time I just opened the web.config file, change something, change it back and save the file and the block started logging again. Second time it stopped logging, opening and saving web.config didn't work until I changed the encoding of the file. Third time I removed the loggingconfiguration section and create the section again to solve the porbolem. Now I simply cannot make it log events anymore and I have tried all my previous solutions and may more.

Could anybody point me to any ideas on how can I make this block work again. As mentioned before, the configuration shown worked more than once. What makes my environment "special" is that my app is runing below a MOSS site so I don;t know if there are guides on what to add and what NOT to add to the a MOSS web.config.

Any help would be greatly appreciated.


Miguel Leal Rosales
Dec 18, 2007 at 11:15 PM
I am having this same problem. Please help anyone. I am about to abandon Enterprise Library because of this.
Dec 19, 2007 at 11:03 AM

I'm not familiar with MOSS to know whether there is a specific reason that precludes logging from happening, so I'd try building from the bottom up: first try to write to the event log using the raw EventLog API, and then I'd try by using a plain .NET EventLogTraceListener through system.diagnostics. If these tests fail, you know the problem lies on the components used by EntLib.

Do other logging mechanisms fail too? Do you get any warnings or errors logged to listeners specified by the "Errors" special source (which I understand may suffer from the same problem you're facing to log in the first place).

Dec 24, 2007 at 3:55 PM

Have you tried checking your EventLog configuration? If the eventlog is full and not set to wrap around then events will not be written. Also if the user the web app is running as does not have write permissions to the registry to write a source to:
  • HKEYLOCALMACHINE\SYSTEM\CurrentControlSet\Services\Eventlog
then it will also fail.

In general if you using the eventlog API to write a message, you need to set up a source if the source does not exist then the eventlog API creates it for you by add a registry entry to the above. If the current active user does not have write permissions to the registry key then it will fail.

The other thing that you need to check is the configuration of category sources and the switches settings, try
  • <add switchValue="All" name="All">

In the event log it should give you a warning message if the category sources are not correctly configured.