Does the Logging Application Block return any exception?

Topics: Logging Application Block
Jun 10, 2009 at 9:14 PM

Hi all,

I have a project developed in .NET 3.5 that uses the EntLib4.1.  In it, there is a call to the Logging Application block:


Logger.Write("Some log message")

The Logging block has been configured to write to a Database Listener.  It works fine in logging the data to the database but my question is, I am trying to put a try-catch between the Logger.Write() and mimicking what happens if there is a failure along the way such as database being down or stored procedure having no proper permission, however, when I tried testing this, the logger.Write() doesn't return any errors, it just doesn't log.  Is there any way I can detect this?


Jun 11, 2009 at 3:14 AM

The Logging Application Block is designed to fail gracefully when such errors occur.  You would have to modify the code if you want the Logger.Write to throw the exceptions.  If you simply want to know if an error occured, you can add a tracelistener like the FormattedEventLog TraceListener under the Logging Errors and Warnings section.  This would cause all exceptions to be logged in the Event Viewer.


Sarah Urmeneta
Global Technology & Solutions
Avande, Inc.

Jun 11, 2009 at 5:02 PM

Ok thank you very much. 

In fact, I'm using an external .config file for the LogWriter and any exceptions would be caught by a custom class that logs the error through the LogWriter.  The problem was that if the exception occurs in the LogWriter itself, there was no way for us to be notified of the error because the logger itself was broken and no exceptions or status is returned. 

Just one more question, when the Logging Application Block fails, how does it handle itself?


Thanks and regards,


Jun 15, 2009 at 9:40 AM

If an error occurs during logging, logs are sent to the tracelisteners under the Logging Errors and Warnings section.  The EventID is always 6352.


Sarah Urmeneta
Global Technology & Solutions
Avande, Inc.