Should logs be stored in a database?

Should logs be stored in a database?

Storing your logs in a database isn’t a HORRIBLE idea, but storing them in the same database as your other production data is. Maybe you’re conservative with your logging and only emit one log line per web request normally.

How do you store error logs?

Use a small database to store all the error logs on the local machine using something light-weight like SQLlite or SQLServer Compact. Save it to a flat file (xml, or what have you) where you can view it. Send it straight to the Event Log.

What is the purpose of a log file?

Log Files are documents that store data about system activity. They are records that contain information about the system. The information includes running applications, services, system errors and messages from the kernel.

Is there a problem with logging to a file?

Part of that framework included also logging to a file, in case the problem is with the database itself, and part of it involves cycling the logs. As for the space issues, the log database is on a different backup schedule, and it’s really not an issue.

Is it good or bad to log to a database?

I think that logging directly to a database is usually a bad idea, and I would avoid it. The main reason is this: a good log will be most useful when you can use it to debug your application post-mortem, once the error has already occurred and you can’t reproduce it.

Why is there no error log in SQL Server?

Your error logging proc is intended to catch other types of error such as constraint violation, conversion errors, permission errors, all these types of error are NOT logged in the SQL Server error log as they are simply programming errors. You did not say that your code is executed in jobs and that there are ssis packages.

What to do if the logging system becomes a problem?

To ensure the logging system does not itself become a problem, there is of course a common code framework we used among different apps that handled writing to the log table. Part of that framework included also logging to a file, in case the problem is with the database itself, and part of it involves cycling the logs.