Inspectopedia 2025.2 Help

String template as argument to logging call

Reports string templates that are used as arguments to SLF4J and Log4j 2 logging methods. The method org.apache.logging.log4j.Logger.log() and its overloads are supported only for all log levels option. String templates 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 (for Kotlin):

val variable1 = getVariable() logger.info("variable1: $variable1")

After the quick-fix is applied (for Kotlin):

val variable1 = getVariable() logger.info("variable1: {}", variable1)

Note that the suggested replacement might not be equivalent to the original code, for example, when string templates contain method calls or assignment expressions.

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.

LoggingStringTemplateAsArgument
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 | JVM languages | Logging

  • Use the Warn on list to ignore certain higher logging levels. Higher logging levels may be always enabled, and the arguments will always be evaluated.

  • Use the Do not warn when only expressions with primitive types, their wrappers or String are included option to ignore string templates, which contain only expressions with primitive types, their wrappers or String. For example, it could be useful to prevent loading lazy collections. Note that, creating string even only with expressions with primitive types, their wrappers or String at runtime can negatively impact performance.

  • Use the Do not warn when call only with an exception as argument after message argument option to ignore calls, which only contain an exception as an argument after the message argument. For example, it could be useful to adjust the inspection's behavior with a custom code style.

New in 2023.1

Inspection options

Here you can find the description of settings available for the String template as argument to logging call inspection, and the reference of their default values.

Warn on

Default value:

debug level and lower

Other available settings:

  • all log levels

  • warn level and lower

  • info level and lower

  • trace level

Do not warn when only expressions with primitive types, their wrappers or String are included

Default value:

Selected
Do not warn when call only with an exception as argument after message argument.

Default value:

Not 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:

//noinspection LoggingStringTemplateAsArgument

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:

IntelliJ IDEA 2025.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025