Exception Handling & Logging - Database/Email TraceListener

Topics: Exception Handling Application Block, Logging Application Block
Sep 6, 2007 at 6:35 AM
I use Exception Handling to catch errors and log to DB:

bool rethrow = ExceptionPolicy.HandleException(ex, "Database Layer Policy");
if (rethrow)
//do something

The log is not being inserted into the table but if I do the code below, the record is there:

LogEntry l = new LogEntry();

Also there are missing LogIDs. (If I use Exception Handling to do the logging 4 times, I will have 4 missing IDs).

Exception Handling with a FlatFile TraceListener works but not with a Database or Email TraceListener.

Hope someone can help.
Sep 6, 2007 at 10:07 AM
Found the reason why the record's not being inserted. The value of the @message parameter is too long causing an error, this will then cause a rollback.