4

I am using ELMAH to log errors in my asp.net MVC(C#) application.

I am able to log errors in xml or database. How to log errors to the eventlog using ELMAH?

2
  • what is the solution you implemented to log errors to eventlog when using ELMAH ? Commented May 28, 2014 at 15:56
  • @Yoda, I have implemented the EventLog.WriteEntry in Application_Error to log the errors in the EventLog Commented May 30, 2014 at 8:16

3 Answers 3

3

ELMAH does not include an event log option.

ELMAH error log classes are not write-only; they also read the log data so that it can be displayed in the ELMAH web interface. Additionally, ELMAH logs more than just exception information. It also logs server variables, the form collection, and the information necessary to reproduce the yellow screen of death. Even if you were to log all of this information to the event log it would be difficult to read as plain text, and very difficult to read back in such a way that the ELMAH web interface could use it. If you are not going to use the ELMAH web interface then clearly that is not an issue.

If you want to log basic exception data to the event log you can create your own error log by subclassing ErrorLog. ELMAH supports multiple error logs, so you could continue to log detailed data to XML or a database (to service the ELMAH web interface) and then log a subset of that data to the event log.

Sign up to request clarification or add additional context in comments.

Comments

1

Out of the box, you can't. You'd have to write a custom handler.

Comments

0

You can do something like this.

Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("My Exception");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.