views:

180

answers:

8

Hi, I'm building a C#/Asp.Net (FW 2.0) web application and I was wondering where I should store my error logs entry.

I could write it on a file on the server, but that doesn't seems right to me. It would be insconsistent with the idea of a database.

The other obivous answer is on the database, but what happened if I do not have any connection with the database. If the client get a connection error to the database what do I do(because the server and the database aren't on the same machine obviously)?

Your suggestions are appreciated.

Than you

Edit : I'm talking about basic error logging here, please do not refer such things as big frameworks like log4net.

+6  A: 

System Event log with appropriate event source (logging channel)

http://support.microsoft.com/kb/307024

Perica Zivkovic
What we do in house is use the System Event Log. That way when we launch we can roll out SCOM and monitor the issues real-time.
Jeremy
A: 

-System Event Viewer
-you may cache your error to local & lightweight db file (can be SqLite/Sql Compact), then when connection is available, you send it to server

Anton Setiawan
A: 

I guess you really have three options:

  1. Use a small database to store all the error logs on the local machine using something light-weight like SQLlite or SQLServer Compact.
  2. Save it to a flat file (xml, or what have you) where you can view it.
  3. Send it straight to the Event Log. (I'd probably do this).
Paperino
+3  A: 

Compared to logging to a DB log4net or nlog are not "big frameworks". Keep it simple and these two provide exactly what you need, with very little ramp up period.

ozczecho
+1  A: 

Store it in the event log; it is designed for this purpose after all! Its the place most people would look for errors, messages and warning regardless of what they know about the application.

The enterprise library provides a framework for logging which you can use Enterprise Library. This allows you to change how/where events are logged based on a configuration file so you don't have to make a decision where events are logged.

In addition to this, if you use the exception handling block you can also log errors to the eventlog with minimal effort

Martin Booth
A: 

log to the database and xml as a fallback, asp.net account will need perms to log errors to eventviewer which may not be such a good idea on the web server unless it is absolutely neccessasy.

TheOCD
+2  A: 

Having a fallback mechanism is a very valid scenario. Logging to the windows event log is often not practical, because it isn't easy to analyze to logs, as is with relational databases. But allowing events to be logged to the event log when your database fails is not a luxury option IMO.

This scenario is one of the reasons I built a logging framework (I won't reference it, just as you requested). It supports a concept called 'fallbackProvider' that allow the event to be logged to an alternative logger in case the main logger fails. When you write your own logging mechanism, you could embrace such a concept.

Good luck.

Steven
Could you give me more information about your framework. Errors stored in the Event Log are hard to retrieve and, as you say, that's not a luxury option.
Frank
Steven
A: 

If you're willing to consider a simple commercial product, take a look at Gibraltar. It stores logs locally then uploads them to a web service when a connection is available. The logs are then indexed in an embedded database and an analysis tool lets you review errors and other information at whatever level of detail you require.

I see that you're a student, Frank. Email me directly to discuss the possibility of us offering you a free license.

Jay Cincotta
I'll take a look, thank you.
Frank
Here are a couple links that might be of interest:Brand new Getting Started video I just finished last weekend: http://www.gibraltarsoftware.com/Try/Getting-Started.aspxBlog article describing the new release we just published a couple days ago: http://rocksolid.gibraltarsoftware.com/development/gibraltar-2-1-1-released
Jay Cincotta