Inspectopedia Help

'Throwable' printed to 'System.out'

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.

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

ThrowablePrintedToSystemOut
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Code maturity

For example, instead of:

try { foo(); } catch (Exception e) { System.out.println(e); }

use the following code:

try { foo(); } catch (Exception e) { logger.warn(e); // logger call may be different }

Availability

By default bundled with

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin

Java, 241.18072

Last modified: 18 June 2024