TextExceptionFormatter outputs inconsistent line endings

Topics: Exception Handling Application Block
Jan 7, 2009 at 6:40 PM
I've noticed that the TextExceptionFormatter outputted line endings of the "Additional Info:" lines in the exception message are "0A" which, when written to a Rolling Flat File trace listener, results in these lines all being running together in a single line that is not easily read.  Some editors interpret "0A" as a line break but not all e.g. Notpad.exe.  The rest of the exception message uses "0D 0A" which result in line breaks as expected in all editors.

I'm using the 4.1 release.  Are these inconsistent line endings a bug?

Thanks,
David

Example follows -

Additional Info:

MachineName : MYLAPTOPTimeStamp : 1/7/2009 6:59:43 PMFullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35AppDomainName : /LM/W3SVC/1/ROOT/AB.CDEFG.HIGJKSITE-13-128758283598980000ThreadIdentity : WindowsIdentity : NT AUTHORITY\NETWORK SERVICE
Jan 8, 2009 at 10:42 AM
Hi,

I have repro your error and verified that the writing of Additional Info writes only a "\a", and others have \r\n, the reason behind the inconsistency of the other items is because, the "\n" is generated by the Ent Lib Source code while the others that has "\r\n" is generated from the config thru its formatter.

Like this one:

<

formatters><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=4.1.0.0, Culture=neutral, PublicKeyToken=null" name="Default Formatter" /> </formatters>

 

 

I  logged this as a bug, here is the reference link.
http://www.codeplex.com/entlib/WorkItem/View.aspx?WorkItemId=20501


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 9, 2009 at 6:31 PM
Thanks Valiant!

BTW the following snippet from ...\Blocks\ExceptionHandling\Src\ExceptionHandling\TextExceptionFormatter.cs shows what needs to be changed to fix this bug:

        protected override void WriteAdditionalInfo(NameValueCollection additionalInformation)
        {
            this.Writer.WriteLine(Resources.AdditionalInfo);
            this.Writer.WriteLine();

            foreach (string name in additionalInformation.AllKeys)
            {
                this.Writer.Write(name);
                this.Writer.Write(" : ");
                this.Writer.Write(additionalInformation[name]);
                //this.Writer.Write("\n"); // Bug
                this.Writer.WriteLine(); // Fix
            }
        }

Jan 12, 2009 at 5:21 AM
Thanks for the Info.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Nov 6, 2009 at 8:24 PM

Hi Valiant,

I see the status of the issue you logged is still Unassigned, will this issue be addressed in the 5.0 release?

Thanks,

David

 

Nov 9, 2009 at 9:47 AM

We'll have to ask the EntLib team regarding this.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Nov 27, 2009 at 9:09 PM

Hi Sarah,

 

Any word from the EntLib team on this issue?

 

Thanks,

David

 

Dec 17, 2009 at 9:19 PM

David, thanks for reporting this. We'll fix it in v5.

Grigori