Reputation: 414
While struggling to see Hibernate-generated SQL queries in JBoss7 log, I'm looking for a definitive answer to following question:
Q: Should entries in both of these config locations be present AT THE SAME TIME, or does any one override another?
1) in log4j.properties
log4j.logger.org.hibernate.SQL=ALL #or DEBUG
2) in persistence.xml
<persistence-unit...>
<properties>
<property name="hibernate.show_sql" value="true"/>
...
This is a vital question for me as I can only edit 1).
Upvotes: 1
Views: 1683
Reputation: 2805
The requirement for logging are these (ofc you have to specify a file appender):
1) on log4j2.xml
//if you put this to trace, you'll log the variables putted into the queries
<logger name="org.hibernate.type" level='trace' additivity="false" >
<appender-ref ref='FileLog'></appender-ref>
</logger>
2) on log4j2.xml
//with debug, you will log the query itself
<logger name='org.hibernate.SQL' level='debug' additivity='false'>
<appender-ref ref='FileLog'></appender-ref>
</logger>
3) on hibernate.cfg.xml
<property name="hibernate.show_sql">true</property>
EDIT: this is an example of appender
<appenders>
<File name="FileLog" fileName="c:/path/your.log"></File>
</appenders>
Upvotes: 2