In my previous post we established that a key factor in professional software development is delivering value to the business - that we are constructing a business asset and that we should be building the greatest possible value into that asset.

One of the less obvious consequences of this perspective is the necessity of delivering more than just the requested features and functionality - those features and functions must be managable in a production environment as well.

The indefatigable Ayende Rahien once wrote on his blog:

A professional system is one that can be supported in production easily. About the most unprofessional thing that you can say is: “I have no idea what is going on.”

Think about this for a minute - when you have finished writing the code, the build is complete and the automated tests pass, when your manual testing phase is complete, the business has signed off and your code is released to production, what happens then?

If you haven’t given any thought to the problem of monitoring the system in production, you might just find your operations team wash their hands of it and pass any and all issues to you - and then you’re stuck providing support instead of creating the next big feature.

Logging is one important way to provide a way to monitor the system - but this involves a lot more than throwing a few tracing statements into some error handlers.

Regular activity needs to be logged - if you only log errors then you’re unable to tell the difference between normal success (nothing logged because nothing is going wrong) and catastrophic failure (nothing logged because nothing is going).

Business operations need to be logged - while the definition of a business operation varies from system to system, each error needs to be handled within the context of the operation that was being attempted when the failure occurred. If you’re not logging any detail about the business operation, good luck sorting out that error.

Logs might contain sensitive data - having logs that are useful enough to troubleshoot problems often means having logs that contain actual data, details of customer activities, SQL used for querying the database, and so on. Without this information the logs may be useless, so the answer is to ensure that only the appropriate staff have access to the logs.

Error logging must be complete - it’s amazing how some developers will log the message out of an exception they’ve caught and believe their work is done. In most environments, an exception contains a wealth of information that is of use for diagnistic purposes; throwing this information away serves no good use and can make it substantially harder to solve the underlying problem.

Logging introduces its own hassles - regardless of the approach you take to logging, it introduces issues that you need to address. For example, you don’t want your production system to go down because your proactive logs fill the disk; nor do you want it to go down because the database used as a log target is temporarily unavailable.

What are you working on at the moment? Does it have a good logging story? If not, why not? - and how are you going to improve it?

Comments

blog comments powered by Disqus
Next Post
Effective IO for the Modern Developer  21 Jun 2015
Prior Post
Of Asset Creation and Business Value  07 Jun 2015
Related Posts
Using Constructors  27 Feb 2023
An Inconvenient API  18 Feb 2023
Method Archetypes  11 Sep 2022
A bash puzzle, solved  02 Jul 2022
A bash puzzle  25 Jun 2022
Improve your troubleshooting by aggregating errors  11 Jun 2022
Improve your troubleshooting by wrapping errors  28 May 2022
Keep your promises  14 May 2022
When are you done?  18 Apr 2022
Fixing GitHub Authentication  28 Nov 2021
Archives
June 2015
2015