views:

480

answers:

6

I'm in the middle of building a pretty big site using asp.net (forms if it's of any interest), and I'm wondering if i need a logging framework such as log4net. I've used such frameworks before, but i don't see how i could put it to any use in this type of project. usually i think logging is needed for customer delivered application, where the log could be sent back and then analyzed for errors. what do you think?

+5  A: 

Heck no - logging is incredibly important for web applications. If you log appropriately, it makes troubleshooting so much easier.

Log4Net is probably a good bet as a framework. You might also want a way of gathering logs together from multiple servers - and even if you don't use more than one server at the moment, it's probably worth suggesting that you will do so at some point.

One option for the centralisation is to copy the logs into a database - see this question for more opinions on that front.

Jon Skeet
+2  A: 

Logs are needed by all type of application. If you ship your application whether customer delivered or inhouse, be it webforms or smartclient/windows applications logging/instrumentation forms the backbone of it.

How will the end user of your application knows the application is working as expected? What will happen if any error occurs? How will the production team diagnose the errors? How will the end user /admin proactively analyse the application and prevent potential future problems?

Since you are using ASP.net, I recommend you also have a look at the "Health Monitoring" features of ASP.net.

You could write your custom events and providers for different types of logging and could configure it for sync/async use.

You could use log4net or enterprise logging block along with "Health Monitoring" and could create a comprehensive logging/instrumentation solution with minimum effort.

rajesh pillai
+1  A: 

I would certainly vouch for enterprise information sink (I think this is the right name, it's a Microsoft api for logging), or Enterprise Library.

I use the latter for all sorts of things such as caching, logging, etc, and it is a very powerful and time saving tool. I also use health monitoring. This is for a large web application that I am building.

You are spoilt for choice when it comes to logging in .NET, and the above two suggestions are great.

dotnetdev
A: 

You can get some pointers from answers to a previous question: what is the best way to write event log entries.

gimel
+1  A: 

Logging is needed if you need to know how application behaves, in which conditions errors occur, who and how has used application (ip address, time, link,...)

Most people use it to trace program execution so they can answer questions like 'why it stopped working?', 'when did it stopped working?' etc.

If you know that applications code too well, and you can easily reproduce problems then I guess logging is overkill for you :)

dario
I cannot totally agree. Logging is not just for diagnostics. It can also be used to do analysis about requests. So, I do logging even the app is coded well.
Morgan Cheng
A: 

You might give Gibraltar a look. It has built-in support for ASP.NET Health Monitoring and provides a wealth of log analysis capabilities. Gibraltar also includes powerful log management of a centralized repository of log data automatically gathered from multiple applications and/or servers.

Jay Cincotta