이 콘텐츠는 선택한 언어로 제공되지 않습니다.
3.2. Component-Specific Logging
Some Platform components have extra logging options available, or extra mechanisms for customizing logging.
3.2.1. SQL Logging with Hibernate 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Hibernate has two ways to enable logging of SQL statements. These statements are most useful during the testing and debugging phases of application development.
The first way is to explicitly enable it in your code.
SessionFactory sf = new Configuration() .setProperty("hibernate.show_sql", "true") // ... .buildSessionFactory();
SessionFactory sf = new Configuration()
.setProperty("hibernate.show_sql", "true")
// ...
.buildSessionFactory();
Alternately, you can configure Hibernate to send all SQL messages to log4j, using a specific facility:
log4j.logger.org.hibernate.SQL=DEBUG, SQL_APPENDER log4j.additivity.org.hibernate.SQL=false
log4j.logger.org.hibernate.SQL=DEBUG, SQL_APPENDER
log4j.additivity.org.hibernate.SQL=false
The
additivity
option controls whether these log messages are propagated upward to parent handlers, and is a matter of preference.