I know I can log exceptions to the database using Log4Net, but I want to break up what it stores for an exception into different columns.
Does anyone know if this is available, if anyone has done this or is it just easier to log exceptions to the database manually?
Cheers
Anthony
UPDATE:
If it helps maybe use the following:
- Does anyone know if this is available?
- These are the sort of details I am after:
- ExceptionType
- ExceptionMessage
- ExceptionSource
- ExceptionTargetSite
- ExceptionStackTrace
- These are the sort of details I am after:
- If anyone has done this?
- Is it just easier to log exceptions to the database manually?
Maybe the change in format will help.
As requested, you can use the approach outlined here: Log4Net available database fields for adoappender – seems there are a few more i.e. method_name? to use custom properties in the log4net
ThreadContextto possibly save this extra information about the exceptions in something like the following:And then in your pattern:
It’s worth testing/researching to see if this is thread-safe (the name would imply that it is, but it can’t hurt to check). You’ll also want to make sure subsequent logs don’t include this data in their messages (i.e, make sure it’s cleared).
(marked was wiki as this isn’t specifically my answer, just a gathering of various info and discussion in the comments on Mitch’s answer).