Hibernate4.3.11 如何去掉红色的日志文字

本文介绍了Hibernate框架的配置过程,包括数据库连接配置、SessionFactory创建及表结构的生成等关键步骤,并展示了具体的日志输出。
​
四月13, 2017 2:41:11 下午 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
四月 13, 2017 2:41:11 下午 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.11.Final}
四月 13, 2017 2:41:11 下午 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
四月 13, 2017 2:41:11 下午 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
四月 13, 2017 2:41:11 下午 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
四月 13, 2017 2:41:11 下午 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
四月 13, 2017 2:41:12 下午 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: com/cch/model/Student.hbm.xml
四月 13, 2017 2:41:12 下午 org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
四月13,2017 2:41:12 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
四月 13, 2017 2:41:12 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/hibernate]
四月 13, 2017 2:41:12 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000046: Connection properties: {user=root, password=****}
四月 13, 2017 2:41:12 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
四月 13, 2017 2:41:12 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
四月 13, 2017 2:41:12 下午 org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
四月 13, 2017 2:41:12 下午 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
四月 13, 2017 2:41:12 下午 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
四月 13, 2017 2:41:13 下午 org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: HHH000227: Running hbm2ddl schema export
Hibernate: 
    drop table if exists Student
Hibernate: 
    drop table if exists _teacher
Hibernate: 
    create table Student (
        id integer not null,
        name varchar(255),
        age integer,
        primary key (id)
    ) type=InnoDB
Hibernate: 
    create table _teacher (
        id integer not null,
        name varchar(255),
        title varchar(255),
        primary key (id)
    ) type=InnoDB
四月 13, 2017 2:41:13 下午 org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: HHH000230: Schema export complete
Hibernate: 
    insert 
    into
        _teacher
        (name, title, id) 
    values
        (?, ?, ?)
四月 13, 2017 2:41:13 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop
INFO: HHH000030: Cleaning up connection pool [jdbc:mysql://localhost:3306/hibernate]

​
  • hibernate默认用的slf4j
  • 导入支持log4j的三个jar包

    导入hibernate包里的lib目录下的optional下的encache下会找到slf4j-api.jar,然后根据这个版本去下载其他两个对应的jar包slf4j-log4j12.jar和log4j12.jar,注意版本的对应。

我的是:log4j-1.2.16.jar+slf4j-api-1.6.1.jar slf4j-log4j12-1.6.1.jar

下载链接:http://download.youkuaiyun.com/detail/hgg923/8435335

  • 找到hibernate-release-4.3.11.Final\project\etc下的log4j.properties

拷进src下修改其中的配置就可以了

保留自己想看的,其它的用'#'注释掉

如:#log4j.logger.org.hibernate=debug

然后测试一下就可以了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cchoop

有用的话请杯肥宅水

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值