Search code examples
c#asp.neterror-logging

What are the best practices for error logging in ASP.NET?


When I worked with Java, I used log4j and slf4j in my web projects. I used next scheme:base class for objects, where I can use inheritance, and static class for other situations.

Now I have project on C#(MVC3). What are the best practices for error logging in C# web applications?


Solution

  • Have a look at log4net. It's similar to log4j (as far as I know) and we're using it all time. It has the ability to be configured via app.config and holds a variety of possibilities to write your logs to (file, rolling file, database, etc.).

    Tip: Avoid writing your logs on a network share. We've tried this and we experienced some huge slow-downs for our entire application with this strategy.