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); }

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

NonStaticFinalLogger
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Logging

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

Here you can find the description of settings available for the Non-constant logger inspection, and the reference of their default values.

Logger class names

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

Availability

By default bundled with

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin

Java, 241.18072

Last modified: 18 June 2024