by emn13 · 13y ago · 0 comments
It's easy to swamp useful messages in tons of noise, so just logging whatever is not necessarily an improvement. Logging means code, and more code means more work, less readability, and more bugs. In particular, logging somewhere, sometime means I/O, which opens up a whole new class of bugs you'd rather avoid. For instance, I've seen several systems go down simply because the disk space ran out.
Logging is also slow - his example of finding a cheapest path is a good example of this. These are well-studied algorithms that explore huge state spaces. Adding logging as he suggests can easily mean the application's running time is spent almost entirely logging. This might not be an issue: maybe you don't need this very often, or maybe the path's aren't very complex, so you can get away with huge overhead because systems are so fast anyhow. But often as not, you can't. And even when you can, you might be adding a trivial DoS vector for your app, or you might be needlessly limiting its applicablity.
If you have an error, it's nice to log whatever you can to help understand it. But the benefit of understanding the odd error more easily needs to be weighed against the non-trivial costs in time, readability, maintainability, disk space and runtime, particularly if you're pre-emptively logging before an error ever occors.
And since it is a circular buffer the memory cost is fixed. Since the memory is shared and available through the filesystem the log stays around if the application crashes.
My main point was this: if you don't get the results you expected, do you know where to start looking for the problem or not? If you have no idea, then there is not enough logging/tracing present in the program.
There's little to gain that way. If the logging was off when the problem happened, you have no logs. You can switch it on and try to reproduce. However, if you are able to reproduce, you can as well attach the process to the debugger and check what's happening. No logging needed.
Logging to disk means I/O.
Apparently when saying logging doesn't require I/O at runtime, you gotta talk it out a lot more before people get it.
Also, if you can turn logging/tracing on and off dynamically, the average volume of output can still be quite manageable.