Logger initialized with foreign class
Logger instances that are initialized with a
class literal from a different class than the
Logger is contained in. This can easily happen when copy-pasting some code from another class and may result in logging events under an unexpected category and cause filters to be applied incorrectly.
A quick-fix is provided to replace the foreign class literal with one from the surrounding class.
After the quick-fix is applied:
Configure the inspection:
Use the table to specify the logger factory classes and logger factory methods recognized by this inspection.
Use the Ignore loggers initialized with a superclass option to ignore loggers that are initialized with a superclass of the class containing the logger.
Use the Ignore loggers in non-public classes to only warn on loggers in
Logger Factory Class Name
[org.apache.log4j.Logger, org.slf4j.LoggerFactory, org.apache.commons.logging.LogFactory, java.util.logging.Logger, org.apache.logging.log4j.LogManager]
Logger Factory Method Name
[getLogger, getLogger, getLog, getLogger, getLogger]
Ignore loggers initialized with a superclass
Ignore loggers in non-public classes
IntelliJ IDEA 2023.3, Qodana for JVM 2023.3