20
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Play+SlickでSQLのログを出力する

Last updated at Posted at 2015-10-06

Play2.4.3 + Slick3.0.0環境で試しました。

build.sbtの依存ライブラリに以下を追加。

"org.slf4j" % "slf4j-nop" % “1.6.4"

conf/logback.xml に以下を追加。

<logger name="slick.jdbc" level="DEBUG" />

そうすると、こんな感じでログが出ます。

[debug] - slick.jdbc.JdbcBackend.statement - Preparing statement: select x2."ID", x2."NAME" from "USERS" x2 order by x2."ID"
[debug] - slick.jdbc.JdbcBackend.benchmark - Execution of prepared statement took 272µs
[debug] - slick.jdbc.StatementInvoker.result - /----+----------\
[debug] - slick.jdbc.StatementInvoker.result - | 1  | 2        |
[debug] - slick.jdbc.StatementInvoker.result - | ID | NAME     |
[debug] - slick.jdbc.StatementInvoker.result - |----+----------|
[debug] - slick.jdbc.StatementInvoker.result - | 1  | hogehoge |
[debug] - slick.jdbc.StatementInvoker.result - | 2  | fugafuga |
[debug] - slick.jdbc.StatementInvoker.result - \----+----------/
20
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?