Two important requirements must be fulfilled when logging messages:

If a program directly writes to the standard output, there is absolutely no way to comply with these requirements. That's why defining and using a dedicated logger is highly recommended.

The following code snippet illustrates this rule:

System.out.println("My Message");  // Non-Compliant

logger.log("My Message");          // Compliant