Logging Configuration Questions

Topics: Logging Application Block
Mar 8, 2007 at 5:05 PM
We are using EL exception handling and logging to e-mail exceptions that our users receive to the developers. So far, we have just used mostly "built-in" messages, but they are very messy and verbose, I am trying to clean up the format. I have two questions:

1. Is there any documentation available on the XML format for the loggingConfiguration section? I would like to see some specific lists of options for the various elements, properties, etc.
2. In a formatter, you can use tokens like {machine} to insert the machine name. I would like the machine name to appear in the subject line of our e-mail. Is there any way to use these tokens in the Email TraceListener?
Mar 9, 2007 at 6:48 PM
Edited Mar 9, 2007 at 6:55 PM
We too use the Logging Application Block to log exceptions. We actually ended up modifying the Logging Application block to meet some of these same needs.

We did two things:

1) Added the title in the subject line instead of severity (which we left in the body) - then we add the machine name and timestamp to the title for exceptions (we decided not to hard code in machine name, since we also use this for logging messages (i.e. non exceptions) and in that case the title may be something different, based on the programmer preference).

2) Added the option for HTML emails (which we use for our exceptions as we can format many things. Then you simply adjust the isBodyHtml attribute to send html vs text emails in the configuration.

It ends up making the exception emails clean - yes they are still verbose because we want as much info as possible such as stack traces, etc., but they are easy to read and divided into formatted sections which makes it easy to identify the cause of the exception.

Here is a sample of what our exception ends up looking like:

Subject: Exception Notification MACHINENAME timestamp

MACHINE NAME timestamp


Client IP: xxx.xxx.xxx.xxx
Thread Identity:
Windows Identity:
Browser: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;.....
Url: http://yourpage.com/wherever.aspx
Referrer: N/A

Exception System.Exception
Message: the exception message here
other fields based on exception type

Stack Trace
stack goes here

then if there are any inner exceptions they follow.

We also alternate background colors across each exception so it is visually cleaner. We construct the extended properties in our business layer which handles the formatting of the exception and any inner exceptions, and passes that data to the logging block which then prints similar to above in the email.

I hope this is helpful information.