To improve the quality of our code, aside from the usual code review of the owners of our application, we ran a code checker. One of the things that it caught is the use of System.out.println. Some of the designers wanted it to be replaced with log4j then configure it to output to console.

Since the application is meant to be run in the command line, I argued that System.out.println should remain because it is not a log but a console message(i.e. “usage: program_name <arg1> <arg2>”). A log, I argued, is different from a console message. Although we can configure log4j to do the same thing, I believe that it should not be used for console messages.

One of them replied that console is only one of the different outputs. And console messages, he argued, like logs tell something about the program.

I just replied:

A console message “can” but not necessarily tell something about the program.

public class HelloWorld {

    public static void main(String []args) {

       System.out.println(“Hello World!”);

    }

}

What do you think? Am I right in asserting that log4j should not be used for things that is not log related?