Formatting the exception message

Topics: Exception Handling Application Block, Logging Application Block
Oct 21, 2008 at 6:29 AM
I have been using the Enterprise Library 2.0 to log the exception by Exception Handling Application Block and Logging Application Block
I used the code in Exception Handling With Logging QuickStart to write into the Event Log and it is working fine.
Now I want to write a log file with minimum information, for example, time stamp & exception message only
I found that the {message} field in the formatters template is too long for me
and I cannot find any methods that I can change the text inside the {message} field by config file

I have tried to implement the TextExceptionFormatter class and override all the WriteXXX function inside (like WriteAdditionalInfo, WriteStackTrace, etc)
when I do nothing in my override functions, it will not write the corresponding text
but I have 1 problem, there is still the HandlingInstanceID that I cannot eliminate it anyway

I think there should have some simple way to do this, can any body help me?

Jerry
Oct 21, 2008 at 10:37 AM
Hi Jerry,

The HandlingInstanceID is added by the logging exception handler itself. This will be changed in 4.1, but in the meantime you'll need to create your own logging exception handler to get rid of this ID.

Fernando
Oct 21, 2008 at 10:54 AM
Hi Fernando,

Oh, do you mean that, I have nothing can do in Enterprise Library 2.0
And I can only wait till 4.1 released, then upgrade my Enterprise Library from 2.0 to 4.1 and implement my logging exception handler?

Hm...it is a bit risky for an application that has no update for a long time
I just want to write some simple log
Anyway, do you know when will 4.1 release?

Jerry
Oct 22, 2008 at 3:25 AM
Hi Jerry,

>do you mean that, I have nothing can do in Enterprise Library 2.0

I think Fernando already answered this question in the last post.
>>in the meantime you'll need to create your own logging exception handler to get rid of this ID.  -fsimonazzi

To make it simpler, if you have the source code for EntLib 2.0, just copy the "ExceptionHandling.Logging" project, renamed the LoggingExceptionHandler to your own name, remove the line of code that adds the "HandlingInstanceID", recompile and configure your app to use this modified Handler.

An