2

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?

2
  • 2
    I'm quite happy with ELMAH at the moment. Personal preference really.. Commented Jun 25, 2013 at 10:05
  • 2
    If you are familiar with log4j, you will find log4net very useful Commented Jun 25, 2013 at 10:05

4 Answers 4

5

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.

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

2 Comments

What kind of appenders will best for use in highload project?
We haven't tried them all. We used a rolling file appender storing the files in a local folder to avoid network load. Works fine for us.
5

I'm surprised that ELMAH is only mentioned in a comment so far. Frank may be familiar with log4j, why log4net may be an obvious choice. Be he is also asking what's the best practices for error logging in C# web applications. ELMAH is the de facto standard error logging component for .NET web applications (Microsoft themselves uses ELMAH as an example in pretty much everything they write about error logging in web applications).

I've written an ELMAH Tutorial, which show you how to get started.

Also if you've already fallen in love with log4net (nothing wrong with that), there's a log4net appender for ELMAH.

Comments

4

I'd say Microsoft Enterprise Library.

http://msdn.microsoft.com/en-us/library/ff648951.aspx

it's easy to use, has many features (like db logger, flat file logger, send to e-mail ...)

Comments

2

Use http://logging.apache.org/log4net/
read this article Log4net is very simple to use yet powerful logging option. This article describes log4net usage in a web application in six easy steps.

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.