As is often the case, the answer is “it depends”. If your application already has a logging framework in place, then you may as well use it. It cannot be less capable than println()
, and you may benefit from other features it provides—stack traces, extra context, better formatting, and so on. There is also the distinct possibility that logging frameworks offer better error recovery, ensuring that your logs are successfully written even in the event of a catastrophic failure.
So the question becomes when to add a logging system in the first place. This is a judgement call: you don’t want to add it too early, only to find out you really have no need for it. You also don’t want to add it too late, and do excessive work converting from your ad-hoc solution.
If you discover that you’re doing a lot of logging with println()
, then your codebase is trying to tell you that it’s experiencing growing pains. At that point, it’s worth it to invest in proper logging.