logback - How to enable trace/debugging output with Anorm on Play 2.4.0 -
with play 2.4.0 anorm got moved external package , logging got changed logback (http://logback.qos.ch)
all , class/package names obvious tracing sql calls.
the "obvious" (based on import statements)
<logger name="anorm" level="trace" />
did nothing , tried
<logger name="anorm.sql" level="trace" />
just in case needed more specific.
google searches dead needed i'm @ loss.
anyone?
you can intercept calls going thru jdbc driver using
log4jdbc
i have used jpa/hibernate , hikary on play 2.4, setup should identically since influences jdbc layer.
add library build.sbt:
"org.bgee.log4jdbc-log4j2" % "log4jdbc-log4j2-jdbc4" % "1.12"
adjust config. add log4jdbc, log4jdbc automatically detects underlying driver string: mysql. if using obscure jdbc driver, can configure using config options - see docs below.
db.default.url="jdbc:log4jdbc:mysql://localhost/......" db.default.driver=net.sf.log4jdbc.sql.jdbcapi.driverspy
example of logback.xml, relevant part:
<logger name="log4jdbc.log4j2" level="error"> <appender-ref ref="stdout" /> <appender-ref ref="file" /> </logger> <logger name="jdbc.sqlonly" level="info" > <appender-ref ref="dbfile" /> </logger> <appender name="dbfile" class="ch.qos.logback.core.fileappender"> <file>${application.home}/logs/sql.log</file> <encoder> <pattern>%date - [%level] - %logger in %thread %n%message%n%xexception%n</pattern> </encoder> </appender>
and, log4jdbc.log4j2.properties (create in conf directory on class path):
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.slf4jspylogdelegator
more docs: https://code.google.com/p/log4jdbc-log4j2/
let me know if works you
Comments
Post a Comment