Logging - Multiple trace listeners

Topics: Exception Handling Application Block, Logging Application Block
Nov 5, 2007 at 3:32 PM

I'm using the enterprise library exception & logging blocks to log exceptions on my server app. I want any exception on the server to be logged to the event log, and also emailed to a mailing list of people who can sort the problems.

Problem is, that this particular server doesn't always have a network connection, so it may not always be able to send out the email. This is ok, but when the network connection is dropped it seems that the email trace listner fails, and causes the other trace listner to fail too, so nothing gets written to the event log. Is there any way to make the trace listners independant of each other (if one fails, the others still run).

I've set up an app.config file and specified an exception policy that uses the Logging Handler for all exception types. The logging handler is setup with a severity of "Error". In the logging configuration section I've got an event log trace listner and an email trace listner, and in the special source/logging errors and warnings section, i've configured it to reference both of these trace listeners.

If anyone knows how to do this (if it's even possible) that would be really great.


Nov 6, 2007 at 12:50 PM
Hi Simon,

Trace listeners for the same source are not isolated from each other, but different sources/categories are, so you could work around this issue by using different categories. This may or may not work for you, depending on the way your logging is structured (eg if you're using differents categories for different layers it might not be so easy).

Hope this helps,
Nov 6, 2007 at 4:55 PM

Thank you very much, that really helps. It's not ideal, but now i know how it works I can come up with a different exception handling stratergy to achive what i need.

Thanks again