I’m using Elmah with ASP.NET and wondering how I would add custom data, such as a session variable, to an unhandled exception email.
I’ve tried several handlers in the Global.asax file but can’t seem to find the right one.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For this, I’d think you would need to modify the Elmah source and recompile. It shouldn’t be too difficult to achieve. If you have a look in the constructor of the
Elmah.Errorclass, theHttpContextis passed in, from which you should be able to get the info you need, e.g. Session, Form variables etc. You could add custom fields to theElmah.Errorclass for this dataI think the
Elmah.ErrorMailHtmlFormatterclass is where the email is constructed using aHtmlTextWriter, and here you could insert code in theRenderSummary()method to include the custom fields you added toElmah.Error.I know it may be a pain to start working with source, but personally I think it’s the cleanest way as there currently is no facility for report/email templates, and it’s better that bolting on something to change the output after it has been generated.