Inspectopedia
 
2024.3

'Throwable' printed to 'System.out'

Warning
New
Last modified: 03 December 2024

Reports calls to System.out.println() with an exception as an argument.

Using print statements for logging exceptions hides the stack trace from you, which can complicate the investigation of the problem. It is recommended that you use logger instead.

Calls to System.out.print(), System.err.println(), and System.err.print() with an exception argument are also reported. It is better to use a logger to log exceptions instead.

The provided quick-fix supports SLF4J and Log4j 2. It replaces System.out.println() call with log calls

Example:

After the quick-fix is applied:

Use the Log method for fix option to specify a method which it is used to log a message.