测试错误ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.问题的解决

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

错误:状态记录器没有找到log4j2配置文件,将使用默认配置:只将错误记录到控制台。

原因:log4j2的jar包是hibernate5框架自带的log4j2,在ssh中即使自己导入了第三方日志包,系统依然会调用log4j2,缺省默认配置文件 log4j2.xml

解决:增加配置文件 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>
  • 配置log4j2后hibernate会向控制台输出更加清晰的信息,当设置成status="warn",你会看到log4j2内部各种详细输出。

  • log4j2.xml可以放在任意的地方,只要你最后把它放到了classpath里,上面的项目中新建一个resources目录用于放置log4j2.xml,如果在未加入classpath时尝试运行时会报错误。

 控制台新出现的hibernate内部日志信息: 

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 

每天进步一点,没个错误都认真记录,点滴进步!!

猜你喜欢

转载自www.cnblogs.com/niusdtz/p/9625414.html