A log message is built with + before the logger checks whether the level is enabled
What it finds
log.debug("loaded " + items) builds the string, calling toString on items, even when debug logging is off and the message is thrown away. The placeholder form, log.debug("loaded {}", items), defers that work until the message is written.
Reported is a call of trace, debug or info on a receiver named like a logger whose first argument concatenates a literal with something that is not a constant.
From the rule's source, eager_log_message.rs.
import org.slf4j.Logger; class Loader { private Logger log; void load(Object items) { log.debug("loaded " + items);tx0 reports: built even when the level is off log.debug("loaded {}", items); log.debug("constant" + " text"); }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:eager-log-message" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:eager-log-message] reason="..."tx0 explain tx0/java:eager-log-message shows the same in the terminal. Found a false positive? Report it.