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.

New in 2023.1