I’m using ELMAH to handle the exceptions in my ASP.Net MVC project. I would like to use it to log errors like database connection timeout, query connection timeout and others. Is this possible with ELMAH?
Share
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.
If you let the exception propogate out to the Elmah Web Module it will automatically log these exceptions.
You can however programatically log directly to Elmah, there are a couple of ways to do this:
You can use code like this in your catch clause in code:
Another way of doing this is this:
I would however wrap this code into a more generic IErrorLogger style interface so that your lower level code doesn’t need to have a hard dependency on Elmah itself