How to print the hibernate parameter binding information?
I have googing,and it does not work.
This is my log4j.properties:
# stdout is set to be a ConsoleAppender.
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-4r [%t] %-5p %l %x - %m%n
log4j.rootLogger=INFO, stdout,requestout
log4j.logger.org.hibernate=INFO;
log4j.logger.org.hibernate.sql=DEBUG;
log4j.logger.org.hibernate.type=trace;
But when start the app,I can only get the log like:
Hibernate: select logentry0_.uri as col_0_0_, count(logentry0_.uri) as col_1_0_ from app.t_log logentry0_ where logentry0_.time between ? and ? group by logentry0_.uri order by col_1_0_ desc
I can 开发者_StackOverflow中文版not see what value is set to the parameter.
Any ideas?
It looks correct in general, but I think it is strange that you write trace
instead of TRACE
and the ;
at line end is also new to me.
So i guess the problem is the log4j syntax.
Apart from setting up Log4J correctly (as axtavt suggested), turn of hibernate.show_sql
property, otherwise you will get duplicated log message: one through your logging framework and a second one printed directly onto the console.
It means that Hibernate log is not going through log4j. Note that Hibernate natively uses slf4j, so you need to add slf4j-log4j binding library to your classpath.
精彩评论