I'm sort of a beginner Java programmer with 2 years of experience. I am creating a small CLI tool with Java for human users (not called by server programs). My Java code got flagged by a code smell detecting tool of my company. The tool said that I shouldn't use System.out
and I should consider using Log4j instead.
I googled a lot on the Internet, but nearly every post starts with something like "...System.out is usually used for quick logging, however, blah blah blah, so you should avoid using it".
How could they assume that System.out
is always used for logging? Nobody even mentioned any other possible use cases of it.
Let's suppose you were developing a new grep
for a Linux shell. You have to print the result of pattern matching to the user, right? I just can't imagine you would use Log4j to do that.
So, to simply put, shall I just totally forget about System.out
? What would you use to output non-log information in Java?