Non-constant string concatenation as argument to logging call
Reports non-constant string concatenations that are used as arguments to SLF4J and Log4j 2 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.
Example:
After the quick-fix is applied:
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.
StringConcatenationArgumentToLogCall- 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.
Configure the inspection:
Use the Warn on list to ignore certain higher logging levels. Higher logging levels may be enabled even in production, and the arguments will always be evaluated.
Inspection ID: StringConcatenationArgumentToLogCall
Inspection options
Here you can find the description of settings available for the Non-constant string concatenation as argument to logging call inspection, and the reference of their default values.
- Warn on
Option ID:
warnLevelDefault value:
all log levelsOther available settings:
warn level and lower
info level and lower
debug level and lower
trace level
- For Log4j 2 use fixes as for parameterized logger
Option ID:
isLog4JParameterizedLoggerDefault value:
Selected
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |