ALOToverflow
ALOToverflow

Reputation: 2699

Where should I store error logs?

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.

Upvotes: 3

Views: 2884

Answers (8)

Jay Cincotta
Jay Cincotta

Reputation: 4386

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.

Upvotes: 0

Steven
Steven

Reputation: 322

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.

Upvotes: 2

TheOCD
TheOCD

Reputation: 161

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.

Upvotes: 0

Martin Booth
Martin Booth

Reputation: 8595

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

Upvotes: 1

ozczecho
ozczecho

Reputation: 8849

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.

Upvotes: 3

bdd
bdd

Reputation: 3434

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).

Upvotes: 0

Anton Setiawan
Anton Setiawan

Reputation: 899

-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

Upvotes: -1

Perica Zivkovic
Perica Zivkovic

Reputation: 2630

System Event log with appropriate event source (logging channel)

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

Upvotes: 6

Related Questions