在play2中哪里可以看到记录的sql语句?
我发现application.conf
中有这样的配置:
# If enabled, log SQL statements being executed.
db.default.logStatements=true
我启用了它,但我找不到任何记录执行sql的日志文件。
我在哪里可以找到它,或者我错过了什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
1. application.conf
确保:
此配置实际上是在 play2 中使用的连接池 Boncp 的设置
2. 自定义记录器
将自定义记录器配置添加到
conf/logger.xml
中。内容可能是:
com.jlbox.bonecp
用于bonecp
,play
和application
用于 play2 。3.禁用application.conf中的logger设置
注释
application.conf
中的logger设置:重新启动游戏,您将看到所有执行的SQL(包括参数值)。
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).
据我所知,这在 Play 2.4.2 中不再有效。默认连接池引擎已更改为 HikariCP。
将其添加到您的 application.conf 并按照以下说明进行操作。事情应该有效:
Application.conf
conf/logger.xml
将自定义记录器配置添加到conf/logger.xml。
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.
只需将以下内容添加到 application.conf (适用于我的 play 2.2.1)
Just add the following to application.conf (works for me in play 2.2.1)
对于 HikariCP(即从 Play 2.4 开始),请参阅 https://github.com/brettwooldridge /HikariCP/wiki/JDBC-日志记录:
对于 log4jdbc-log4j2:将
"org.bgee.log4jdbc-log4j2" % "log4jdbc-log4j2-jdbc4.1" % "1.16"
添加到libraryDependencies
中;配置说明位于 https://code.google.com/archive/p/log4jdbc -log4j2/。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/.