Our Ops group requested that we add some data to our exception logs. Everything they are looking for can easily be obtained from the HttpRequest object, but I can't tell the best way to get that information into the Exception so it can be handled and logged
by the EHAB. I've seen approaches from writing custom ExceptionHandler and ExceptionFormatter objects, to just putting the data into the Exception.Data property.
I've got a pretty short turn around time for this. Any suggestions on best practices or preferred approach?
Nate Southerland, MCSD.NET
You will be happy that it is much simpler than that. You can add the information you need to the exception class like:
// Add Data That Will Get in Log
bool rethrow = ExceptionPolicy.HandleException(ex, "LoggingPolicy");
By adding the data to the exception as shown above, the same information will get into the log.
Conceptually, the logginghandler copies the exception data to the LogEntry.ExtendedProperties to be logged by the TraceListener(s).
Just make sure your Formatter Template contains the appropriate tokens to display the ExtendedProperties in the log.
Microsoft MVP C#