Enterprise Library Logging Issue

Topics: Logging Application Block
Dec 18, 2012 at 4:45 PM

I have C# datacontract, one of the datamember is byte array. Im serializing this object using XmlSerializer and pass that string to Enterprise logger. I noticed that some time the logger does not log this serialized datacontract in the event viewer, However note that i all other logs.

I think its the size of the object after serialization. So is there any settings that i need to do so that it will log large string also.

Also if enterprise library itself throwing error then where would that error will get logged?

Im using Windows 2008 r2 server

Dec 19, 2012 at 12:45 AM

If you are logging to the Event Log then there is definitely a maximum to the message size you can log.  So, in general, the Event Log is not a great choice to write arbitrarily long data.  In the .NET 3.5 reference it is listed as 32766 bytes.  Subsequent versions of the documentation do not mention this limit so I'm not sure if it has changed (e.g. http://serverfault.com/questions/402124/event-log-message-size-31885-windows-2008).

To capture Enterprise Library Logging Application Block errors you should configure the errors special source.  I usually recommend using a Flat File Trace Listener that is configured to write to a location known to have proper permissions.  Here is what the XML would look like:

    <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
            <add name="Error Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                fileName="D:\Logs\errors.log" header="" footer="" />
            <allEvents switchValue="All" name="All Events" />
            <notProcessed switchValue="All" name="Unprocessed Category" />
            <errors switchValue="All" name="Logging Errors & Warnings">
                    <add name="Error Flat File Trace Listener" />

Randy Levy
Enterprise Library support engineer
Support How-to