Parameterize logging statements

MSAL

Transform logging statements using concatenation for messages and variables into a parameterized format. For example, logger.info("hi " + userName) becomes logger.info("hi {}", userName). This can significantly boost performance for messages that otherwise would be assembled with String concatenation. Particularly impactful when the log level is not enabled, as no work is done to assemble the message.

org.openrewrite.java.logging.ParameterizedLogging

Required

A method used to find matching statements to parameterize.

Optional

removeToStringBoolean

Optionally remove toString() method invocations from Object parameters.

mod run . --recipe=org.openrewrite.java.logging.ParameterizedLogging \ -P methodPattern='org.slf4j.Logger info(..)'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.