Implementing Exception logging xml to Sql2005 instead of Event log

Topics: Building and extending application blocks, Exception Handling Application Block, General discussion, Logging Application Block
Jan 11, 2009 at 4:43 PM
Edited Jan 11, 2009 at 8:33 PM
Could anyone let us know the steps to implement the exception handling and logging with Exception logged as XML
and along with custom object which can then be logged to SQL 2005 database instead of Event log.
Jan 12, 2009 at 5:11 AM

Try following this steps.

Assuming that you already have the config file...

1. Add a Exception Handling Application Block.
2. Add a Exception Policy.
3. In your exception policy, add the desired Exception Type.
4. In the added exception type, add a Logging Handler.
           After the the Logging Handler has been added, the Logging Block is also added.
5. In the Logging Block, In the TraceListeners node, Add a new XMLTraceListener.
6. In the properties of your XMLTraceListener specify the FileName property, its where the log will be saved.
7. In the category node of your Logging Block, you can add a new category and then add a new Trace Listener Reference referencing your XMLTraceListener or you can just use the default category.
8. In your Logging Handler properties, specify the FormattedType as XMLExceptionFormatter.
9. In your Logging Handler properties, set the LogCategory to the category where your XMLTraceListener resides.

Hope this Helps.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.