I found there is such a configuration in application.conf
:
# If enabled, log SQL statements being executed.
db.default.logStatements=true
I've enabled it, but I can't find any log file which logged executed sqls.
Where can I find it, or do I miss something?
Just add the following to application.conf (works for me in play 2.2.1)
1. application.conf
make sure:
This config is actually a setting of bonecp which is connection pool used in play2
2. custom logger
Add a custom logger configuration to
conf/logger.xml
.The content may be:
The
com.jlbox.bonecp
is forbonecp
, andplay
andapplication
are for play2.3. disable logger settings in application.conf
Comment the logger settings in
application.conf
:Restart play, and you will see all executed SQLs(including parameter values).
This no longer works in Play 2.4.2 from what I can tell. The default connection pool engine was changed over to HikariCP.
Add this to your application.conf and follow the directions below. Things should work:
Application.conf
conf/logger.xml Add a custom logger configuration to conf/logger.xml.
For HikariCP (i.e. starting with Play 2.4), see https://github.com/brettwooldridge/HikariCP/wiki/JDBC-Logging:
For log4jdbc-log4j2: add
"org.bgee.log4jdbc-log4j2" % "log4jdbc-log4j2-jdbc4.1" % "1.16"
tolibraryDependencies
; configuration is described at https://code.google.com/archive/p/log4jdbc-log4j2/.