Skip to content
BENIBIX Learn

Print Debugging vs Logging

People think print debugging is the same as logging, and it is not. Print lines are short-lived. You add them to chase one bug, then delete them. Logging stays in the code for good. It writes events with a time and a level, so people can read them long after the code ran.

Development🛠️ Editors & Tools

Print Debugging

Adding lines that print values as the code runs. They show where it goes wrong.

Print debugging is finding a bug by adding lines that print values while the program runs. You put a print line at each step you are unsure about. When you run the code, the lines show each value and the order the steps ran in. The first value that looks wrong points to the bug. Once the bug is fixed, you take the extra lines out again.

Example
Jack's shopping cart always shows a total of 0. He adds a print line before and after the sum. The first one already prints a price of 0, so the bug is where the price is read in.
Why it matters
It works in any language and on any machine. It even works where a debugger cannot reach.
Full entry
Infrastructure📈 Monitoring & Observability

Logging

Writing down what a program does, one timed line per event.

Logging is writing down events, one line at a time, as a program runs. Each line, called a log entry, has a time, a level and a message. It might say a user logged in, or a payment failed. The lines go to a file or to a tool that gathers logs from many servers. Logs are the place to look for the details of one event.

Example
A payment fails for one buyer. Jack searches the logs for the order number and finds the line saying the card was refused.
Why it matters
When something breaks, the log is often the only record of what took place.
Full entry

In one line

Print Debugging
Adding lines that print values as the code runs. They show where it goes wrong.
Logging
Writing down what a program does, one timed line per event.

These live in different corners of the glossary (Development and Infrastructure), which is exactly why they get confused.