Play Framework 2.0和Ebean SQL日志记录 [英] Play Framework 2.0 and Ebean SQL logging
问题描述
我想检查Ebean生成了哪些SQL语句,以找出为什么我的Play 2.0应用程序中发生某些异常(与SQL语法有关)的原因. 是否可以在Play Framework 2.0中记录Ebean生成的SQL语句?
I want to examine what SQL statements are generated by Ebean to find out why certain exceptions (related to SQL syntax) are occurring in my Play 2.0 application. Is there a way to log the SQL statements generated by Ebean in Play Framework 2.0?
在Play 1.x中,有一个jpa.debugSQL
配置选项,如果将其设置为true,它将执行此操作. Play 2.0是否存在类似的针对Ebean的设置?关于Play 2.0的Ebean的文档页面仍然有点稀缺.
In Play 1.x, there is a jpa.debugSQL
config option, which if set to true, will do exactly this. Does a similar setting for Ebean exist for Play 2.0? The documentation page about Ebean of Play 2.0 is still a bit scarce.
到目前为止,我已经尝试过:
我已经在控制器和Global对象的onStart
/onRequest
方法中添加了这些方法调用,但没有任何作用:
I have added these method calls in my controllers and the onStart
/ onRequest
methods of the Global object, but it doesn't have any effect:
Ebean.getServer(null).getAdminLogging().setLogLevel(LogLevel.SQL);
Ebean.getServer(null).getAdminLogging().setDebugGeneratedSql(Play.isDev());
我已经修改了application.conf
的日志级别,但也没有帮助(即使使用日志级别TRACE
).
I have modified the log levels from application.conf
, but it didn't help either (even with log level TRACE
).
推荐答案
很抱歉聚会晚了,但是我在开发中使用了它:
Sorry to be late to the party, but I use this in development:
db.default.logStatements=true
logger.com.jolbox=DEBUG
将这两行添加到application.conf中,您就很好了.
Add those two lines to the application.conf and you are good to go.
它输出所有sql语句.希望对您有所帮助.
It outputs all the sql statements. Hope it helps.
这篇关于Play Framework 2.0和Ebean SQL日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!