Search code examples
javaxmlloggingconsolelog4j2

WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release


I use log4j2.xml to write my logs into a local file in my Maven project. I've installed the last dependencies for present day <version>2.20.0</version>) in pom.xml. My log4j2.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp" packages="">
    <Appenders>
        <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz">
            <TimeFilter start="01:00:00" end="07:00:00" onMatch="ACCEPT" onMismatch="DENY"/>

            <PatternLayout>
                <pattern>%d %p %c{1.} [%t] %m%n</pattern>
            </PatternLayout>
            <TimeBasedTriggeringPolicy />
        </RollingFile>
    </Appenders>
    <Loggers>
        <Root level="error">
            <AppenderRef ref="RollingFile"/>
        </Root>
    </Loggers>
</Configuration>

My dependencies in pom.xml:

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <version>2.20.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <version>2.20.0</version>
    </dependency>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <version>2.20.0</version>
    </dependency>

When I start my main method logs successfully be written in a file, but I get the message in IntelliJ IDEA console:

WARN StatusConsoleListener The use of package scanning to locate plugins is deprecated and will be removed in a future release

How can I resolve the problem? just want to stop appearing the message in console.


Solution

  • This warning is caused by using the packages attribute of the Configuration element in the log4j2.xml file, because it has been deprecated. Removing that attribute should prevent the message from appearing.