我無法用log4j2創建休眠日誌消息。它只記錄INFO和WARN。另一方面,HikariCP完全適用於這個配置。下面是pom.xml中:Log4j2/JPA /休眠日誌不起作用
... <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:
<?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是最新的4.3.7。它使用jboss日誌記錄,根據文檔,它應該適用於log4j2。 – 2014-11-23 11:22:25