For anything beyond a quick check.
WHY LOGGING RATHER THAN PRINTING
Levels, so you can control verbosity Destinations, so output can go to a file Formatting, including timestamps It can be left in place
THAT LAST POINT
Print statements get removed and re-added constantly.
Logging stays, and is silenced by configuration.
WHAT THE LEVELS ARE FOR
Detailed diagnostic information Routine progress Something unexpected but handled An error A serious failure
WHAT TO SET IN DEVELOPMENT
A verbose level.
WHAT TO SET IN PRODUCTION
A level recording what matters without excessive volume.
WHAT TO INCLUDE IN A MESSAGE
What happened, with the relevant values.
A message saying only "error" is useless.
WHAT NOT TO LOG
Credentials Full personal data Every iteration of a loop
WHERE TO CONFIGURE IT
Once, at application startup.
WHAT TO AVOID
Configuring logging inside library code Several competing configurations