Is it better to log to file or database?

Viewed 21775

We're still using old Classic ASP and want to log whenever a user does something in our application. We'll write a generic subroutine to take in the details we want to log.

Should we log this to, say, a txt file using FileSystemObject or log it to a MS SQL database?

In the database, should we add a new table to the one existing database or should we use a separate database?

5 Answers

Looking at the responses, I think the answer may actually be both.

If it's a user error that's likely to happen during expected usage (e.g. user enters an invalid email etc.), that should go into a database to take advantage of easy queries.

If it's a code error that shouldn't happen (can't get username of a logged in user), that should be reserved for a txt file.

This also nicely splits the errors between non-critical and critical. Hopefully the critical error list stays small!

I'm creating a quick prototype of a new project right now, so I'll stick with txt for now.

On another note, email is great for this. Arguably you could just email them to a "bug" account and not store them locally. However this shares the database risk of bad connections.

Related