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.properties
Configuration 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.