0

I have a C#.net site which displays custom error pages to the user. This is set in web.config:

<customErrors mode="Off">
      <error statusCode="500" redirect="~/error.cshtml" />
      <error statusCode="404" redirect="~/error.cshtml" />
</customErrors>

The problem is that if there is an error, I have no record of what it was. I'm familiar with PHP where I can set a location for the error_log file which I can then check for PHP errors. Is there a way to do something similar in .NET?

2

4 Answers 4

1

You can use log4net dll, it has provisions to log errors as well as diagnostic messages.

Link where the log4net is available :

https://logging.apache.org/log4net/release/example-apps.html

Codeproject demo to get started :

http://www.codeproject.com/Articles/8245/A-Brief-Introduction-to-the-log-net-logging-librar

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

Comments

0

You can try NLog. Here is a Tutorial

Comments

0

You can use the built-in logging functionality that comes with ASP.NET.

Set it up in system.diagnostics in web.config, declare a trace source in your code and off you go.

You can configure it to write to the event log as well as log files and custom destinations.

I just did a quick google search and found an introductory article here: http://www.thejoyofcode.com/from_zero_to_logging_with_system_diagnostics_in_15_minutes.aspx

You will find many more without too much effort.

Comments

0

Have a look at the HealthMonitoring possibilities that come with ASP.Net. For instance, you can get references to exceptions and send emails with the exception to a specified address. A couple of years ago I wrote this article about HealthMonitoring: http://www.tomot.de/en-us/article/6/asp.net/how-to-create-a-custom-healthmonitoring-provider-that-sends-e-mails

If you want a more mature error logging solution, have a look at Elmah.

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.