.NET - registering and monitoring exceptions

What is the best way to track exception registration in a production environment? I have an application in which exceptions are written to a text file. Every time I need access to these log files, I received a request from the backoffice command to send me a copy.

To improvise this process, I thought of several options:

1) Send error logs regularly

2) Save the log file in the database

3) Create some kind of listener objects for monitoring logs (is this possible?)

Is there a better option and how to implement it?

TIA

+7
logging exception monitoring
source share
5 answers

I highly recommend log4net . You can do any type of logging with it, and besides, there is even an example of SMPTAppender on the documentation page found here . Thus, you can really send exceptions directly to anyone, you can store them in the database, the possibilities are really endless.

+2
source share

You should try Error Logging Modules and Error Handlers (ELMAH) .

ELMAH is a free, open source error logging library. It includes features such as:

  • Error filtering
  • View errors on a web page (custom user roles)
  • RSS feed
  • Download as CSV File
  • Programmatically raise an exception directly to it
  • Email Notifications

Information on how to install and use can be checked on your page.

additional literature

For more information on the topics discussed in this tutorial, see the following resources:

+5
source share

I’m sure that your back office team can set up access directly to the logs if you quickly talk about how to do it safely.

Personally, I write a lot of material into the log files, because any information can be useful for a difficult situation. But I also log exceptions directly in the database and display them on a secure page, so I can use this as a starting point.

+1
source share

Elmah and log4net are great solutions, especially if you need to store log and exception data in the package. They still require you to set up email accounts or log in to receive securely stored logs.

Another option - if your data can be stored in the cloud - there are exception monitoring services such as Appfail and Airbrake . These are cloud exception monitoring services.

For example, using Appfail you connect a reporting module (similar to the ELMAH reporting module), which will report exceptions from your web service. You can then log in to view crash analytics and register to receive notifications of important failures.

** Disclaimer: I'm working on Appfail :-)

+1
source share

You can consider Seq - this is a server that you can install in your own environment (MSI setup), then send logs to use NLog, log4net or Serilog .

Once your applications send logs to Seq, you can request them using the web interface or configure handlers that notify you, perhaps by email, but really in any way you choose: handlers can be written in C # and connected .

I am working on both products, so obviously this is not an unbiased opinion, but after many years of using log4net and text files, a jump to centralized logging and fully structured events is a pretty huge step forward.

Serilog is open source (Apache2 on GitHub) and supports many reverse and output formats. Seq is commercial, but offers a very convenient free version.

+1
source share

All Articles