Skip navigation.

Debugging vs. logging

I, personally, consider the use of debuggers, with breakpoints and stepping through individual statements to be very much a waste of time... especially as languages have evolved to have expect/require, and even a drop into a REPL.

To borrow a quote of a quote from Log4J (or Log4cpp):

As Brian W. Kernighan and Rob Pike put it in their truly excellent book "The Practice of Programming"

As personal choice, we tend not to use debuggers beyond getting a
stack trace or the value of a variable or two. One reason is that it
is easy to get lost in details of complicated data structures and
control flow; we find stepping through a program less productive
than thinking harder and adding output statements and self-checking
code at critical places. Clicking over statements takes longer than
scanning the output of judiciously-placed displays. It takes less
time to decide where to put print statements than to single-step to
the critical section of code, even assuming we know where that
is. More important, debugging statements stay with the program;
debugging sessions are transient.
Logging does have its drawbacks. It can slow down an application. If too verbose, it can cause scrolling blindness. To alleviate these concerns, log4j is designed to be reliable, fast and extensible. Since logging is rarely the main focus of an application, the log4j API strives to be simple to understand and to use.

Avoiding debuggers, is particularly good with languages now supporting Threads, Actors, and true parallelisms... A debugger tends to execute in a linear manner, which would be contrary to a functional and threaded/asynchronous programming paradigm.