Hibernate learning: SLF4J log Frame

Source: Internet
Author: User

One: First look at a diagram



Commons-logging and SLF4J are log interfaces for use by users, without providing implementations! The Log4j,slf4j-nop in the back is their realization.


II: The Slf4j-api-1.5.8.jar of Hibernate framework

Hibernate defaults to the Slf4j-nop.jar log implementation method.

But we can replace the implementation of log4j. But not simply add Log4j-1.2.17.jar on the line. A converter is also required in the middle slf4j-log4j12-1.5.8.jar



Then add log4j.properties to the SRC directory


# # # Direct log messages to stdout # # #log4j. appender.stdout= org.apache.log4j.consoleappenderlog4j.appender.stdout.target=system.outlog4j.appender.stdout.layout= Org.apache.log4j.patternlayoutlog4j.appender.stdout.layout.conversionpattern=%d{absolute}%5p%c{1}:%L-%m%n### Set log levels-for more verbose logging "info" to ' Debug ' # # #log4j. Rootlogger=warn, Stdout#log4j.logger.org.hiber nate=info#log4j.logger.org.hibernate=debug### Log HQL Query parser activity#log4j.logger.org.hibernate.hql.ast.ast= debug### log just the sql#log4j.logger.org.hibernate.sql=debug### log JDBC bind Parameters # # # # log4j.logger.org.hibernate.type=info#log4j.logger.org.hibernate.type=debug### Log Schema Export/update # # # log4j.logger.org.hibernate.tool.hbm2ddl=debug### log HQL Parse trees#log4j.logger.org.hibernate.hql=debug### log Cache Activity # # # #log4j. logger.org.hibernate.cache=debug### Log Transaction activity# log4j.logger.org.hibernate.transaction=debug### Log JDBC resource Acquisition#log4j.logger.org.hibernate.jdbc=debug### enable the following line if you want to track down connection ###### leakages when using Driv Ermanagerconnectionprovider # # # #log4j. logger.org.hibernate.connection.drivermanagerconnectionprovider=trace


Log output:

22:12:18,627 INFO schemaupdate:155-running HBM2DDL schema update
22:12:18,629 INFO schemaupdate:167-fetching Database metadata
22:12:18,630 INFO schemaupdate:179-updating Schema
22:12:18,647 INFO tablemetadata:65-table Found:hibernate.teacher
22:12:18,647 INFO tablemetadata:66-columns: [ID, title, name]
22:12:18,647 INFO tablemetadata:68-foreign keys: []
22:12:18,647 INFO tablemetadata:69-indexes: [Primary]
22:12:18,648 INFO Schemaupdate:217-schema Update complete
Hibernate:insert into Teacher (name, title, id) VALUES (?,?,?)



Hibernate learning: SLF4J log Frame

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.