play framework Logging ebean SQL statments

可紊 提交于 2020-01-17 03:06:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!