mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
38 lines
1.3 KiB
HTML
38 lines
1.3 KiB
HTML
<html>
|
|
<body>
|
|
Reports non-constant string concatenations that are used as arguments to <b>SLF4J</b> and <b>Log4j 2</b> logging methods.
|
|
Non-constant concatenations are evaluated at runtime even when the logging message is not logged; this can negatively impact performance.
|
|
It is recommended to use a parameterized log message instead, which will not be evaluated when logging is disabled.
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
<b>public class</b> Vital {
|
|
<b>private static final</b> Logger LOG = LoggerFactory.getLogger(Vital.class);
|
|
|
|
<b>public void</b> saveTheWorld(<b>int</b> i, String s, <b>boolean</b> b) {
|
|
LOG.info("saveTheWorld(" + i + ", " + s + ", " + b + ")");
|
|
// todo
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
<b>public class</b> Vital {
|
|
<b>private static final</b> Logger LOG = LoggerFactory.getLogger(Vital.class);
|
|
|
|
<b>public void</b> saveTheWorld(<b>int</b> i, String s, <b>boolean</b> b) {
|
|
LOG.info("saveTheWorld({}, {}, {})", i, s, b);
|
|
// todo
|
|
}
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>
|
|
Configure the inspection:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
Use the <b>Warn on</b> list to ignore certain higher logging levels. Higher logging levels may be enabled even in production, and the arguments will always be evaluated.
|
|
</li>
|
|
</ul>
|
|
</body>
|
|
</html> |