LoginSignup
3
6

More than 5 years have passed since last update.

SQL ログを出力する

Posted at

conf/application.conf で以下の設定を有効化すると、playframework が実行する SQL ログをコンソールに出力することができます。

# Debug SQL statements (logged using DEBUG level):
jpa.debugSQL=true

ただ、これだけではバインドされた変数の値は分かりません。こちらは conf/application.conflog4j.properties に Hibernate のオプションを指定することで出力することができます。

# You can even specify additional hibernate properties here:
# hibernate.use_sql_comments=true
# ...
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.use_sql_comments=true
log4j.logger.org.hibernate=INFO, hb
log4j.logger.org.hibernate.SQL=DEBUG
log4j.logger.org.hibernate.type=TRACE
log4j.logger.org.hibernate.hql.ast.AST=info
log4j.logger.org.hibernate.tool.hbm2ddl=warn
log4j.logger.org.hibernate.hql=debug
log4j.logger.org.hibernate.cache=info
log4j.logger.org.hibernate.jdbc=debug

log4j.appender.hb=org.apache.log4j.ConsoleAppender
log4j.appender.hb.layout=org.apache.log4j.PatternLayout
log4j.appender.hb.layout.ConversionPattern=HibernateLog --> %d{HH:mm:ss} %-5p %c - %m%n
log4j.appender.hb.Threshold=TRACE

参考

3
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6