Hibernate 4.3.6日志记录无法使用log4j2

时间:2014-09-29 05:50:27

标签: hibernate logging configuration log4j2 jboss-logging

我无法使用以下配置来使用hibernate来记录任何内容:

<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.0.2</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.0.2</version>
  </dependency>
  <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
  </dependency>
  <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>4.3.5.Final</version>
  </dependency>
  <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>4.3.5.Final</version>
  </dependency>


</dependencies>

这是我的log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" >
  <Appenders>
    <Console name="CONSOLE" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
    </Console>
  </Appenders>
  <Loggers>
    <Root level="all">
            <AppenderRef ref="CONSOLE" />
    </Root>
    <Logger name="org.hibernate" level="all"/>

  </Loggers>
</Configuration>

我还在主要方法中添加了System.setProperty("org.jboss.logging.provider", "log4j2")http://docs.jboss.org/hibernate/orm/4.3/topical/html/logging/Logging.html指定 但没有效果。有什么指针吗?

由于

1 个答案:

答案 0 :(得分:4)

This bug report表示Log4j2日志记录桥已损坏。它抛出一个NPE!在发布之前,有没有人测试过它?我打算绕过SLF4j