问题
I'm using play 2.2.0 How cam I log ebean sql I tried
db.default.logStatements=true
logger.com.jolbox=DEBUG
In config file but no luck. should I add any code to my models or create extra config files? what Is the configuration working for this version?
回答1:
Hi you need to add logger.xml to your /conf/logger.xml
.
<configuration>
<timestamp key="bySecond" datePattern="yyyy_MM_dd_HH_mm"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-5level - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/application-${bySecond}.txt</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread %n%message%n%xException%n</pattern>
</encoder>
</appender>
<logger name="com.jolbox.bonecp" level="DEBUG">
<appender-ref ref="FILE" />
</logger>
<logger name="com.jolbox.bonecp" level="DEBUG">
<appender-ref ref="STDOUT" />
</logger>
<logger name="play" level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
<logger name="application" level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
</configuration>
This: com.jolbox.bonecp
will be adding all sql to console and will write to file application-currentdate.log
.
来源:https://stackoverflow.com/questions/20375926/play-framework-logging-ebean-sql-statments