I am writing a command line java application for a task of converting the content of a file to a json file. In here I want to get the response whether the operation is successful or not printed in the command line. For this I have two options,
- To use System.out.println (sout)
- To use a logger (eg:- java.util.logging.Logger)
I find the response shown in command line when using sout is more clear since it does not show texts related to logging (as an example INFO: My response message).
On the other hand I got to know that using sout is not a good practice (See Sonar rule java:s106).
I want to know which way is better and why?
Here is my code in the main method with the logger approach.
public static void main(String[] args) {
        try {
            Executor executor = ExecutorFactory.getExecutor(args);
            executor.execute();
        } catch (ExecutorException e) {
            logger.log(Level.INFO, e.getMessage());
        }
    }
Let's say e.getMessage() gives "No matching file found" as the result.
This is what I get as the response in the command line.
INFO: No matching file found
I would like it to be more clean. This is what I expect.
No matching file found
Should I use sout for this purpose or is there another way?
 
    