ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console

created at 10-29-2021 views: 46

error

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

mistake

The status logger did not find the log4j2 configuration file and will use the default configuration: only errors are logged to the console.

reason

The jar package of log4j2 is log4j2 that comes with the hibernate5 framework. Even if you import a third-party log package in ssh, the system will still call log4j2. The default configuration file is log4j2.xml.

solution

Add configuration file log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>

<Configuration status="warn">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%m%n" />
        </Console>
    </Appenders>
    <Loggers>
        <Root level="INFO">
            <AppenderRef ref="Console" />
        </Root>
    </Loggers>
</Configuration>
  • After log4j2 is configured, hibernate will output clearer information to the console. When set to status="warn", you will see various detailed output inside log4j2.
  • log4j2.xml can be placed anywhere, as long as you finally put it in the classpath, create a new resources directory in the above project to store log4j2.xml, if you try to run it without adding the classpath, an error will be reported.

The new hibernate internal log information in the console:

08:01:59,522 INFO C3P0Registry:216 - Initializing c3p0-0.9.2.1 [built 20-March-2013 10:47:27 +0000; debug? true; trace: 10]
HHH000412: Hibernate Core {5.0.7.Final}
HHH000206: hibernate.properties not found
HHH000021: Bytecode provider name : javassist
HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
08:02:00,084 INFO AbstractPoolBackedDataSource:522 - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts 
created at:10-29-2021
edited at: 10-29-2021: