Using a Debugger or a Log to Find Bugs

When you have a bug in your software, you cannot always just read the code to find the cause of the bug. Two techniques are used for further investigation: the debugger allow to follow the execution of the code, while writing logs allow write multiple snapshots of contexts. In this article, Henrik Warne explains why you cannot rely only on a debugger to find bugs.

There are many benefits from the usage of logs in bug discovery. When the software architecture becomes complex, you need to examine the full sequence of events that leads to the problem and not only the situation when the bug is actually triggered. To use the debugger, you need to know the code. With a log, situations can always be analyzed even by non developers sometimes. Finally, it is also a good tool that you can use on a production system where it is not always possible to use a debugger. One of the main argument against logs is that they can be detrimental to the application’s performance. This can be however decreased if you code your logging statements wisely and if you have a mechanism that allows to turn off the log or to target only specific items, accounts numbers for instance, in your log.

The conclusion of the article is that “There are many cases where your only option is using a debugger in order to figure out what the problem is. Even great log statements can’t cover all cases. But by using logging wisely, you can cut down substantially the number of times the debugger is needed, while at the same time getting all the benefits of logging.”

Read the complete article on