本文介绍了Log4j2 / JPA / Hibernate日志记录不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法使用log4j2制作休眠日志消息。它只记录INFO和WARN。另一方面,HikariCP完全适用于这个配置。这里是pom.xml:
I can't make hibernate log messages with log4j2. It logs only INFO and WARN. On the other side HikariCP works perfectly with this config. Here is the pom.xml:
... <dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.1</version>
</dependency> ...
log4j2.xml:
log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
</Console>
</Appenders>
<Loggers>
<!--<Logger name="org.apache.log4j.xml" level="debug"/>-->
<Root level="info">
<AppenderRef ref="STDOUT"/>
</Root>
<Logger name="org.hibernate" level="debug"/>
<Logger name="org.hibernate.SQL" level="debug"/>
<Logger name="com.zaxxer.hikari" level="debug" />
</Loggers>
</Configuration>
推荐答案
我找到了解决方案。 Hibernate肯定使用jboss日志记录,所以与hibernate-core和hibernate-entitymanager一起提供的版本是3.1.3.GA,当它升级到最新的3.2.0时.Final一切都开始正常工作。
I found the solution. Hibernate definitely uses jboss-logging, so the version coming with hibernate-core and hibernate-entitymanager is 3.1.3.GA and when it gets upgraded to the latest 3.2.0.Final everything has started to work normally.
这篇关于Log4j2 / JPA / Hibernate日志记录不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!