Logging exceptions for logging listeners

Topics: General discussion, Logging Application Block
Feb 18, 2011 at 4:51 PM

How can I log/debug listener failures?  For example, I have an application that uses the enterprise library 5.0 logging.  I have the following listeners, FlatFile Listener, Custom Listener outputting to console window and Database Listener.  My intention is I would use the output in the Custom/Consoler listener when running the application manually.  However, this application will be called by an automatted process normally.  Therefore, the logging will be saved into the database for review.  However, if the database logging fails, I have a flatfile listener for backup.

Here is my problem.  If the database logging fails for whatever reason (permission, database offline, etc), the logging in flat file still occurs which is perfect.  However, I have no information as to why the database logging failed.  The flat file log looks normal.  I am concerned that if there is a problem that is difficult to debug as to why a certain listener is not working properly, I might be stuck.

Is there any way to add to the output using the EL 5.0 logging not only my log write statements, but also any listener failures.

Any insight would be appreciated.

Thanks,
Dan

Feb 20, 2011 at 12:53 PM

Exceptions occurred while logging can be configured to be logged using the Logging Errors and warnings trace source.  Just reference the trace listener which you want to write the logging failures under that category.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Feb 28, 2011 at 12:20 AM
AvanadeSupport wrote:

Exceptions occurred while logging can be configured to be logged using the Logging Errors and warnings trace source.  Just reference the trace listener which you want to write the logging failures under that category.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com


Could you please clarify this answer or give a code sample. Its not obvious for me.

Feb 28, 2011 at 2:05 AM
Edited Feb 28, 2011 at 2:10 AM

By default, logging of errors is automatically enabled after you add the Logging Application Block. It uses Event Log as its trace listener. You can see it in Enterprise Library configuration as shown below:


Logging Settings