ppkarwasz commented on issue #2363: URL: https://github.com/apache/logging-log4j2/issues/2363#issuecomment-1993767405
@SeasonPanPan, Today there is an increasing amount of tools to check or reformat logging code: - Palantir's [`LoggerInterpolationConsumesThrowable`](https://github.com/palantir/gradle-baseline/blob/develop/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/LoggerInterpolationConsumesThrowable.java) Error Prone rule seems to perfectly fit your problem and can pinpoint the location of problematic log statements, - there is a very active OpenRewrite Logging Frameworks project that offers [many recipes](https://docs.openrewrite.org/recipes/java/logging) to automatically clean up logging code. I have opened a feature request openrewrite/rewrite-logging-frameworks#141 to extend the existing `CompleteExceptionLogging` recipe to your use case. If you have many statements to fix, maybe it is easier to contribute this feature and rewrite your statements automatically. >``` >2024-03-12T23:55:03.063Z main ERROR Unable to format msg: first param is {}, second param is {} >java.lang.IllegalArgumentException: found 2 argument placeholders, but provided 1 for pattern `first param is {}, second param is {}` > at org.apache.logging.log4j.message.ParameterFormatter.formatMessage(ParameterFormatter.java:248) >``` This behavior was introduced in 2.21.0 and corrected in #2343, to provide a uniform way of handling missing log statement parameters (the same way `StringFormattedMessage` does it for `String#format` formatted messages). In my personal experience, it is better to detect this kind of errors early in the release cycle. With the previous behavior I remember staring at a **literal** `{}` in a production log, because I forgot the relevant parameter in the code. I am not strongly opinionated regarding this behavior though: we could still fill in the provided parameters, but **keep** the status logger error message. @vy, what do you think? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org