Logging statements are valuable. Don't throw them away!


I'm a bit ashamed to admit, but at Zemanta we use print statements a lot while debugging our code. We have improved our coding practices a lot in the past year though (mostly thanks to code reviews), so we have at least stopped committing print statements to the code repository and therefore our logs are no longer completely polluted with relics of past debugging strifes. Developers spend considerable amount of their time instrumenting code by logging important data structures or code paths in order to understand code's behaviour. If the instrumentalization code is not commited to the repository, it will have to be rewritten (or commented in) again the next time the developer will be debugging the code. By using standard logging libraries such as Python logging or Log4j the developer is able to selectively control logging level in each module in a local configuration file and therefore there is no need to remove instrumentalization code before commiting to repository. On the contrary, the instrumentalization code becomes a valuable asset in the next debugging battle.

I wonder what your logging practices are? Please tell about your experience in comments.