Hi,
I'm trying to log the hibernate generate SQLs to a file using log4j. I've referenced several posts and website with instruction related to this, but I can't seem to get the SQLs in the file.
I'm using Spring 3.0.0.RC1 & Hibernate 3.3.2
I have set hibernate.show_sql=true, hibernate.use_sql_comments=true & hibernate.format_sql=true
I have the Spring Log4jConfigListener configured before the ContextLoaderListener in my web.xml
Code:
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/configs/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
In my log4j.properties I have this
Code:
log4j.logger.org.hibernate.SQL=ALL, HIBERNATE
log4j.additivity.org.hibernate.SQL=false
log4j.logger.org.hibernate.type=INFO, HIBERNATE
log4j.appender.HIBERNATE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.HIBERNATE.File=${webapp.root}/sql.log
log4j.appender.HIBERNATE.DatePattern='.'yyyy-MM-dd-HH
log4j.appender.HIBERNATE.layout=org.apache.log4j.PatternLayout
log4j.appender.HIBERNATE.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
I see the SQL on the console, but in nothing in the sql.log
Any idea what is missing??
Thanks in advance!