Inspectopedia Help

Logger initialized with foreign class

Reports Logger instances initialized with a class literal other than the class the Logger resides in.

This can happen when copy-pasting from another class. It may result in logging events under an unexpected category and incorrect filtering.

Use the inspection options to specify the logger factory classes and methods recognized by this inspection.

Example:

class AnotherService class MyService { private val logger = LoggerFactory.getLogger(AnotherService::class.java) }

After the quick-fix is applied:

class MyService { private val logger = LoggerFactory.getLogger(MyService::class.java) }

Inspection options

Option

Type

Default

Table

None

Logger Factory Class Name

TableColumn

[java.util.logging.Logger, org.slf4j.LoggerFactory, org.apache.commons.logging.LogFactory, org.apache.log4j.Logger, org.apache.logging.log4j.LogManager]

Logger Factory Method Name

TableColumn

[getLogger, getLogger, getLog, getLogger, getLogger]

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023