A logger is named after another class than the one it is declared in
What it finds
private static final Logger LOG = LoggerFactory.getLogger(OrderService.class); in UserService sends its messages under the name of OrderService, so they are filtered and configured as if they came from there. This usually happens when a class is copied.
Reported is a field initialized with getLogger of a class literal whose class is neither the class of the field nor a class around it.
From the rule's source, logger_of_other_class.rs.
import org.slf4j.Logger;import org.slf4j.LoggerFactory; class UserService { private static final Logger LOG = LoggerFactory.getLogger(OrderService.class);tx0 reports: named after OrderService private static final Logger OWN = LoggerFactory.getLogger(UserService.class); static class Inner { private static final Logger INNER = LoggerFactory.getLogger(UserService.class); }} class OrderService {} 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:logger-of-other-class" = "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:logger-of-other-class] reason="..."tx0 explain tx0/java:logger-of-other-class shows the same in the terminal. Found a false positive? Report it.