Inspectopedia Help

Non-constant logger

Reports logger fields that are not declared static and/or final. Ensuring that every class logger is effectively constant and bound to that class simplifies the task of providing a unified logging implementation for an application.

A quick-fix is provided to change the logger modifiers to static final.

Example:

public class Significant { private Logger LOG = Logger.getLogger(Critical.class); }

After the quick-fix is applied:

public class Significant { private static final Logger LOG = Logger.getLogger(Critical.class); }

Configure the inspection:

  • Use the Logger class name table to specify logger class names. The inspection will report the fields that are not static and final and are of the type equal to one of the specified class names.

Inspection options

Option

Type

Default

Logger class names

StringList

[java.util.logging.Logger, org.slf4j.Logger, org.apache.commons.logging.Log, org.apache.log4j.Logger, org.apache.logging.log4j.Logger]

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023