我最近在我的pom.xml中添加了hibernate,它工作得很好。然而,日志记录是令人恼火的,我不知道如何关闭它或限制它的水平(我甚至不知道它到底包括什么来启动所有这些日志记录)。我是新来的,对maven和 hibernate 。
下面是我的pom.xml依赖:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.1.Final</version>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.10</version>
</dependency>
</dependencies>
日志是这样开始的:
21:17:15.115 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
21:17:15.130 [main] DEBUG org.hibernate.type.BasicTypeRegistry - Adding type registration boolean -> org.hibernate.type.BooleanType@ba4d54
21:17:15.130 [main] DEBUG org.hibernate.type.BasicTypeRegistry - Adding type registration boolean -> org.hibernate.type.BooleanType@ba4d54
21:17:15.130 [main] DEBUG org.hibernate.type.BasicTypeRegistry - Adding type registration java.lang.Boolean -> org.hibernate.type.BooleanType@ba4d54
我试过添加一个log4j.properties文件到我的资源,它似乎没有改变任何东西。我还尝试了simplelog.properties(跟随其他没有帮助的SO帖子)。我被困在这里了,如果能帮忙的话我会很感激的。理想情况下,我想只是设置日志记录器关闭,或只是mysql查询。
这是一个依赖树:
[INFO] org.springframework:gs-rest-service:jar:0.1.0
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.1.10.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.1.10.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:1.1.10.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.1.10.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.1.10.RELEASE:compile
[INFO] | | | +- org.slf4j:jcl-over-slf4j:jar:1.7.7:compile
[INFO] | | | | \- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] | | | +- org.slf4j:jul-to-slf4j:jar:1.7.7:compile
[INFO] | | | +- org.slf4j:log4j-over-slf4j:jar:1.7.7:compile
[INFO] | | | \- ch.qos.logback:logback-classic:jar:1.1.2:compile
[INFO] | | | \- ch.qos.logback:logback-core:jar:1.1.2:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.13:runtime
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.1.10.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:7.0.57:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:7.0.57:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:7.0.57:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:7.0.57:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.3.4:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.4:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.3.4:compile
[INFO] | +- org.hibernate:hibernate-validator:jar:5.0.3.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.0.0:compile
[INFO] | +- org.springframework:spring-core:jar:4.0.8.RELEASE:compile
[INFO] | +- org.springframework:spring-web:jar:4.0.8.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:4.0.8.RELEASE:compile
[INFO] | | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | | +- org.springframework:spring-beans:jar:4.0.8.RELEASE:compile
[INFO] | | \- org.springframework:spring-context:jar:4.0.8.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:4.0.8.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.0.8.RELEASE:compile
[INFO] +- org.hibernate:hibernate-core:jar:4.0.1.Final:compile
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.0.CR2:compile
[INFO] | +- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] | \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile
[INFO] +- org.hibernate.common:hibernate-commons-annotations:jar:tests:4.0.1.Final:compile
[INFO] \- mysql:mysql-connector-java:jar:5.1.10:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.918 s
[INFO] Finished at: 2015-02-07T22:09:37+00:00
[INFO] Final Memory: 20M/203M
[INFO] ------------------------------------------------------------------------
1条答案
按热度按时间wsxa1bj11#
您可能在日志框架配置中设置了一个全局
DEBUG
日志级别。您需要做的就是将
org.hibernate
日志级别设置为WARN
或ERROR
: