intermediateLogging

Why does log.info("msg={}", value) use a placeholder instead of string concatenation?

The `{}` placeholder defers building the actual string until the logging framework confirms this log level is enabled — string concatenation (`"msg=" + value`) always runs regardless of whether the log line will even be emitted, wasting work on every disabled DEBUG/TRACE call in production.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why is logging every request at INFO level a bad default for a production service?← Back to all Spring Boot questions