gpt4 book ai didi

java - Hibernate:在没有 log4j 的情况下禁用日志记录到控制台

转载 作者:行者123 更新时间:2023-11-29 08:52:29 25 4
gpt4 key购买 nike

我有 hibernate 模式,我想减少控制台每次运行时发生的日志记录。我的应用程序中没有 log4j,也不想添加它。

这是我每次运行我的应用程序时获得的日志示例

Feb 25, 2014 6:36:41 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
Feb 25, 2014 6:36:41 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.1.Final}
Feb 25, 2014 6:36:41 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Feb 25, 2014 6:36:41 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Feb 25, 2014 6:36:41 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Feb 25, 2014 6:36:41 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Feb 25, 2014 6:36:42 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Feb 25, 2014 6:36:42 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
Feb 25, 2014 6:36:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
Feb 25, 2014 6:36:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000401: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost:5432/hibernatedb]
Feb 25, 2014 6:36:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000046: Connection properties: {user=Sidney, password=****}
Feb 25, 2014 6:36:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
Feb 25, 2014 6:36:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
Feb 25, 2014 6:36:43 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
Feb 25, 2014 6:36:43 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
Feb 25, 2014 6:36:43 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
Feb 25, 2014 6:36:43 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Feb 25, 2014 6:36:44 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: HHH000227: Running hbm2ddl schema export
Feb 25, 2014 6:36:44 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: HHH000230: Schema export complete

这是我的 hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.driver_class">org.postgresql.Driver</property>
<!-- <property name="connection.url">jdbc:mysql://localhost:3306/hibernateDB</property> -->
<property name="connection.url">jdbc:postgresql://localhost:5432/hibernatedb</property>
<property name="connection.username">**</property>
<property name="connection.password">**</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<!-- <property name="dialect">org.hibernate.dialect.MySQLDialect</property> -->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">false</property>

<!-- Drop the existing tables and create new one -->
<property name="hbm2ddl.auto">create</property>

<!-- Mention here all the model classes along with their package name -->

<!-- <mapping class="edu.cs157b.hibernate.Student"/> -->
<mapping class="edu.cs157b.hibernate.Doctor"/>

</session-factory>
</hibernate-configuration>

最佳答案

根据您的日志详细信息,我了解到 Hibernate 版本是 Hibernate 4.0.4.Final。从 4.0 版开始,Hibernate 使用了JBoss 日志库,因此甚至您的应用程序不包含任何 log4j 仍然 hibernate 正在使用 JBoss 日志记录提供程序作为默认提供程序。有关更多信息,请访问此链接:

http://docs.jboss.org/hibernate/orm/4.3/topical/html/logging/Logging.html

希望此信息能帮助您理解为什么日志在没有任何 log4j 的情况下仍然可用。

关于java - Hibernate:在没有 log4j 的情况下禁用日志记录到控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22030677/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com