Files
openide/java/java-impl/resources/inspectionDescriptions/ThrowablePrintedToSystemOut.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

31 lines
1.0 KiB
HTML

<html>
<body>
Reports calls to <code>System.out.println()</code> with an exception as an argument.
<p>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.</p>
<p>Calls to <code>System.out.print()</code>, <code>System.err.println()</code>, and <code>System.err.print()</code> with an exception argument are also
reported. It is better to use a logger to log exceptions instead.</p>
<p>The provided quick-fix supports <b>SLF4J</b> and <b>Log4j 2</b>.
It replaces <code>System.out.println()</code> call with log calls</p>
<p><b>Example:</b></p>
<pre><code>
try {
foo();
} catch (Exception e) {
System.out.println(e);
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
try {
foo();
} catch (Exception e) {
log.error("e: ", e);
}
</code></pre>
<!-- tooltip end -->
<p>
Use the <b>Log method for fix</b> option to specify a method which it is used to log a message.
</p>
</body>
</html>