Hibernate3 uses the configuration and implementation of integrated log4j

Source: Internet
Author: User

The default log framework provided by hibernate3 is slf4j. The SLF of hibernate3 is only a log interface, while the default log framework provided by hibernate3 is rarely used by companies or projects in actual development, here we record a log framework that uses log4j to replace the implementation of the slf4j log framework. The specific configuration and implementation are as follows:

I. added the log4j log framework

(1. slf4j-api-1.6.1.jar files, is the previous reference hibernate3 built-in log API (provides a variety of log interfaces ).

2. The log4j-1.2.16.jar file is the framework of log4j.

3. The slf4j-log4j12-1.6.1.jar file is the adapter for the conversion between the log interface of hibernate3 and log4j.

 

2. Add the log4j configuration fileLog4j. properties, go to the class path, and set the log level.

log4j.propertiesConfiguration item description:

org.hibernate.SQL 
Logs are recorded when all SQL DML statements are executed.

org.hibernate.type 
Logs for all JDBC Parameters

org.hibernate.tool.hbm2ddl 
Logs are recorded when all SQL DDL statements are executed.

org.hibernate.pretty 
During session cleansing (flush), logs are recorded for the status of all entities associated with it (up to 20 ).

org.hibernate.cache 
Logs of all second-level cache activities

org.hibernate.transaction 
Logs of transaction-related activities

org.hibernate.jdbc 
Logs for obtaining all JDBC Resources

org.hibernate.hql.AST 
Record the ast analysis logs of hql and SQL during resolution query.

org.hibernate.secure 
Logs for JAAS authentication requests

org.hibernate 
Logs for any hibernate-related information (large amount of information, but very helpful for error detection)

 

Note: before configuring the preceding log types, add "log4j. Logger.", for example, log4j.logger.org. hibernate. hql = debug.

 

3. Log debugging is now available.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.