What is the best way to treat Exceptions and Log in Webapi (C#)?

Asked

Viewed 220 times

1

Setting: Webapis in . NET 4.x

Goal: Improve Logging (info, error, debug, Warning) and Exception Handling, for example, log in exceptions, which Log frameworks do you use? Where do you store Logs? I found a tool called Datadog anyone’s ever seen ?

I found these Steps here too: https://stackoverflow.com/questions/16028919/catch-all-unhandled-exceptions-in-asp-net-web-api

Edit

My question was marked as duplicate.. but I did not find anything related to the context (EXCEPTION + LOG).. just Log... my focus is Exception too.

  • Ever worked with log4net? It works with text files and databases. Its installation and configuration is not complex. It searches it...

2 answers

1

I recommend taking a look at Log4net that is very popular and it is possible to find interesting content in Portuguese (Ex: Macoratti) and in the Elmah which is a very complete and very interesting tool.

1


I think about the storage location, I like tools that store in N locations, the log has to persist you can not stay refer to a means of access to it. That’s why I use serilog , it persists in several form including in the database and files (Which are the most used).

I don’t know Datadog, but in general the tools are very similar, try to find one that suits you and has a lot of users that is the case of serilog and log4net, so you ensure good maintenance in case of problems in them. The important thing is the good treatment in the code and a good infrastructure to store.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.