Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
623 views
in Technique[技术] by (71.8m points)

playframework 2.0 - Play Framework 2.0 and Ebean SQL logging

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?

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.


What I have tried so far:

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());

I have modified the log levels from application.conf, but it didn't help either (even with log level TRACE).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Sorry to be late to the party, but I use this in development:

db.default.logStatements=true

logger.com.jolbox=DEBUG

Add those two lines to the application.conf and you are good to go.

It outputs all the sql statements. Hope it helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...