views:

297

answers:

4

I've got an application in test that's logging events for a departmental Windows forms application to a SQL Server database. The application is nearly ready for production. The logging database is completely separate from the application database.

My question is, do I really need to create a production version of the logging database, or can I just log production and test events to the same database? The obvious answer is yes, of course I need a separate database. You never want test and production environments to mix. But in this case, the data being written to the database isn't really production data, exactly, it's just logging details that we use to troubleshoot problems. It has no business value, and nothing significant would be lost if the data were to be inadvertently dropped or the database were to be temporarily unavailable. And having it all in a test environment would make it much simpler for me to manage.

So on a pros and cons basis using a single logging database for all environments seems like a better solution. But it just doesn't feel right. Can anybody give me any specific reasons why this is a bad idea?

+1  A: 

I would say:

Use a standard methodology for logging (a single DLL or similar) and actually house the logging DB in production.

That way, your logging database can be considered a "Logging Server" and ALL apps (Dev, Staging, Test, and Prod) can log to it, since you are using a vetted library.

Of course, you have to still watch out that you don't flood the server...

John Gietzen
Thanks. I actually am using a single DLL that wraps log4net. I hadn't thought of pointing everything to production. Good suggestion.
John M Gant
Agreed. Logging everything to production sounds reasonable. If you're relying on the production server anyway, then this method won't make your application any less reliable.
Steve Wortham
A: 

Keeping logs on a database is a bad idea in the first place. What happens when you can't connect to the DB for some reason or another? I suggest you use log4net and implement RollingFileAppenders. They write log entries to a file and when the file hits a certain limit, log4net starts writing to a new file. If you have questions getting setup, feel free to ask. I would be glad to help!

Artel
Thanks for the post. I've actually used RollingFileAppenders quite a bit. They work great for web applications, but I've run into permissions and file I/O problems using them with my Windows application (probably unique to our enterprise, but still real problems), which is why I'm going with the database appender. See my other post at http://stackoverflow.com/questions/727462/where-to-write-log-for-windows-app.
John M Gant
+1  A: 

I don't see anything wrong with keeping it on the dev box, unless your app will fail if it's unable to properly log, or unless the information being logged is more valuable than you indicate.

On the upside, keeping your logging db on your dev server will help take the load for handling this data off of the production server - a definite plus where performance is concerned.

Aaron Alton
Interesting point. Taking the load off production is good, but the DBAs may not like me routing production-level traffic to a test server.
John M Gant
Good point. Again, the dev server idea is only a good one *if* your logging mechanism is tolerant of downtime in your logging db.
Aaron Alton
+2  A: 

Your logging may not work if your dev server is down but prod isn't. Can guarantee that will be when something critical you need logged on prod will happen. In our case prod and dev are not in the same physical location which would mean sending logging data across our network and cause pipeline bottlenecks and cranky network guys.

Plus what if you decide to change the logging process? While you are doing new development, the entire prod process might break.

And there will be times when someone might read lthe logs, panic at some error forgetting that it happened on dev. Or worse, someone might see a bad error that they thought was happening on dev that was really happening on prod.

HLGEM
All good points I hadn't considered. Thanks.
John M Gant