Special Categories - Logging Errors & Warnings

Topics: Logging Application Block
May 10, 2012 at 5:39 AM
Edited May 10, 2012 at 5:42 AM


i set up the Logging Errors & Warnings to send email to me whenever error occured..already set the minimum severity to Error

but when Exception caught, it doesn't send anything to me..i have to explicitly create LogWriter to do that..

is this suppose to be use like this?

my goal is to send an email for the error to me so i can fix the program immediately whenever exception raised



May 10, 2012 at 6:41 AM

Special Categories - Logging Errors & Warnings is used when an internal error occurs within the Logging Application Block while processing a Write request.  

Let's say you have configured the logging Application Block with an EmailTraceListener (associated with the "General" category) and you try to log something using Logger.Write("Test", "General") but while sending the email an error occurs (SMTP is down, port blocked, etc.) then the error information along with the original  message will be logged to any Trace Listeners configured in the Logging Errors & Warnings Special Source.  Usually for the Logging Errors & Warnings Special Source I recommend using a dedicated Flat File Trace Listener since it is less likely to have an error itself.  

If your code is catching an exception and you want to log that information then, yes, you will need to explicitly log the error.  Or perhaps use the Exception Handling Block with a Logging Exception Handler.  Another approach for dealing with these cross cutting concerns is to use Unity Interception with the Logging Call Handler to log the exception information (send an email).

Randy Levy
Enterprise Library support engineer