Entlib 3.1 Logging problem

Aug 14, 2007 at 10:14 AM

I having a weird problem - I cannot write to XMLTraceListener under web project.
I think it might relate to security issues after all... though I set everyone full control (frustration settings :( ) on the log folder.

I am using the May 2007 version for logging - when I use it for a windows form or a service, everything works fine.
When I implement it into a web project, I can only log to XMLTraceListener the Info, Verbose & Warning (see config). the Error & Critical fails to write to the file (also flat file & rolling file) and I get the following error (by email):

Timestamp: 14/08/2007 08:56:40
Message: Tracing to LogSource 'All Events' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks.

here comes the log I logged

Exception Information Details:
Exception Type: System.Xml.XmlException
LineNumber: 16
LinePosition: 73
Message: An error occurred while parsing EntityName. Line 16, position 73.
Data: System.Collections.ListDictionaryInternal
TargetSite: Void Throw(System.Exception)
HelpLink: NULL
Source: System.Xml

StackTrace Information Details:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, Int32 lineNo, Int32 linePos)
at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos)
at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
at System.Xml.XmlTextReaderImpl.ParseText()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XPath.XPathDocument.LoadFromReader(XmlReader reader, XmlSpace space)
at System.Xml.XPath.XPathDocument..ctor(TextReader textReader)
at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener.GetXml(LogEntry logEntry)
at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogSource.TraceData(TraceEventType eventType, Int32 id, LogEntry logEntry, TraceListenerFilter traceListenerFilter)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter.ProcessLog(LogEntry log)
Priority: -1
EventId: 6352
Severity: Error
Application Domain: /LM/W3SVC/1/Root/MyWeb-1-128315544428373462
Process Id: 2096
Process Name: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_wp.exe
Win32 Thread Id: 10004
Thread Name:
Extended Properties:


My configuration is like this:
<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="" logWarningsWhenNoCategoriesMatch="true">
<add toAddress="myemail" fromAddress="sender email"
subjectLineStarter="TestLogger:DevTest:" subjectLineEnder=""
smtpServer="smtpserver" smtpPort="25" formatter="TextFormatter"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="EmailTraceListener" />
<add source="TestLogger" formatter="TextFormatter" 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="EventLogTraceListener" />
<add fileName="C:\Logs\TestLogger.svclog" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.XmlTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="XMLTraceListener" />
<add template="{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})}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="LineFormatter" />
<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="TextFormatter" />
<add enabled="true" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="LogEnabled Filter" />
<add minimumPriority="-1" maximumPriority="2147483647" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Priority Filter" />
<add switchValue="All" name="ActivityTracing" />
<add switchValue="All" name="Critical">
<add name="EmailTraceListener" />
<add name="EventLogTraceListener" />
<add switchValue="All" name="Error">
<add name="EmailTraceListener" />
<add name="EventLogTraceListener" />
<add switchValue="All" name="Information" />
<add switchValue="All" name="Verbose">
<add name="EmailTraceListener" />
<add switchValue="All" name="Warning">
<add name="EmailTraceListener" />
<add name="EventLogTraceListener" />
<allEvents switchValue="All" name="All Events">
<add name="XMLTraceListener" />
<notProcessed switchValue="All" name="Unprocessed Category">
<add name="EventLogTraceListener" />
<add name="EmailTraceListener" />
<errors switchValue="All" name="Logging Errors & Warnings">
<add name="EmailTraceListener" />
<add name="EventLogTraceListener" />

Mar 18, 2008 at 12:06 AM
Edited Mar 18, 2008 at 6:04 PM
The first problem solved, there was a problem with smtp server when the entlib tried to send email. but the incorrect date problem still exists. Hope I can get help on it today :) thanks all.
---------Last post---------------
I have the same problem, try to log, successfully write to the db but entlib added the following extra record:
plus in both cases, the the timestamp is wrong : 3/17/2008 10:40:58 PM instead of 3.40 PM,
Appreciate your help very much.

event id: 6352 , priority = -1
here is the error.
Tracing to LogSource 'Error' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks.

Summary for Enterprise Library Distributor Service:
Timestamp: 3/17/2008 10:40:58 PM
Message: System.DivideByZeroException
Attempted to divide by zero.
Void HandleSystemExceptionFromUILogOnly()
at ExceptionManagementTest.ExceptionManagerTest.HandleSystemExceptionFromUILogOnly() in C:\ExceptionManagerTest.cs:line 546

Category: Error
Priority: 1
EventId: 100
Severity: Error
Machine: mymachinename
App Domain: UnitTestAdapterDomainFor .... 2008-03-17 1540_04\Out\ExceptionManagementTest.dll
ProcessId: 1496
Process Name: C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\vstesthost.exe
Thread Name: AdpaterExeMgrThread1
Win32 ThreadId:2660
Extended Properties:
--> MachineName: mymchinename --> TimeStamp: 3/17/2008 10:41:09 PM
--> FullName: Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
--> AppDomainName: UnitTestAdapterDomain_For C:\Code
Mar 27, 2008 at 2:57 PM
I am seeing a similar problem. I have my sources set up correctly and it does log to XML and the Event Application log correctly - EXCEPT when I am handling an exception from another process or thread. An example is a call to a WCF that is not runnning. Under that circumstance, the Eventlog has a correct entry based on my configuration, by the write to the XML log fails. This is noted in the Eventlog as a second error message.

We are having similar problems in the WCF. Some messages are being lost. It appears to be related to which thread was running, although the actual logging is done in one thread and a lock is obtained before a message can be added to the queue.

This seems like a bug, not a configuration or application issue. Assuming that is true, how does one report a bug? Who owns the Enterprise Library? Microsoft or CodePlex?
Jul 3, 2008 at 9:07 PM
I am having similar problems with EntLib 4.0. Does anyone have more to offer? This exception seems to be related to a bogus entity name in the xml data - something along the lines of &bogus; in the data I suppose. I can't find any place where my data contains anything matching this pattern so it is possibly data gathered up elsewhere. Either way, I am expecting lower level code to ensure that log entries are compatible with xml.
Jun 1, 2009 at 5:17 PM

Did this ever get resolved.  I have a custom trace listener and am getting the same error when I call TraceData()

InnerListener.TraceData(eventCache, source, eventType, id, data);

Is this a bug handling "&"? 

Jun 8, 2009 at 2:50 PM

I upgraded to 4.1 and this issue appears to have gone away.  So that is the good news.  The upgrade was pretty painless, just updating all the project refernces. Just don't forget you have to manually upgrade your config files and if you are editing them using the Enterprise Library Configuration use the 4.1 version. Also don't forget ObjectBulider2.dll - that one slipped by on me - but we have 40 projects or so:-)