Search code examples
.netelmah

Logging exception context in ELMAH


By default ELMAH logs:

  • Exception name
  • Exception message
  • Stack trace
  • Date
  • Server variables

I know there's been a discussion about logging exception's data dictionary, here: https://code.google.com/p/elmah/issues/detail?id=162

I know we can store our custom message in ELMAH using Signal -> Raise mechanism:

ErrorSignal.FromCurrentContext().Raise

Does anyone know if there's functionality to customize error template? I mean extending or changing logged information, so we can store some additional value inside single ELMAH entry?

I'm asking because I'm trying to put GUID information into exception system, so user can give support team exact information about issue (SharePoint errors appear that way).


Solution

  • There's no way to store custom data with ELMAH at the moments. There's a few options though. You could fork ELMAH and implement this yourself. You would do that by extending the error log implementation you're using to persist the Data dictionary. We've done this on elmah.io and the implementation were pretty straight forward. You should parse the Data dictionary like this and persist in SQL server or whatever data store you're using.