Reputation:
I've reviewed a couple of questions/answers here around the subject, but nothing works out-of-the-box. I've also read the SqlLogger section in the official documentation, but still I can't find a way log/visualize what Jdbi (version 3.x
) "is doing" when it interacts with the database? — in a straightforward way.
I'm aware Jdbi is using almost raw SQL, but it's always nice to be able to see what is it what the framework/library says it's doing for debugging purposes, etc.
I've tried pretty much any namespace starting from org.jdbi
(within a logback.xml
file), up until trace
mode, but I just see something like this:
03-01-2021 19:52:26,656 |- TRACE in org.jdbi.v3.core.Jdbi:315 [reactor-http-epoll-2] - Jdbi [org.jdbi.v3.core.Jdbi@7a76fb45] obtain handle [org.jdbi.v3.core.Handle@725d5aec] in 0ms
03-01-2021 19:52:26,697 |- TRACE in org.jdbi.v3.core.Handle:187 [reactor-http-epoll-2] - Handle [org.jdbi.v3.core.Handle@725d5aec] released
Is there a way to do this these days?
Upvotes: 0
Views: 733
Reputation:
This work landed on pull request 1828. From now on, by setting the log level to debug
on org.jdbi.sql
, all the interactions with the database will be printed out...that simple!
Upvotes: 0
Reputation: 231
Not a JDBI answer, but more generic way to see raw SQL is to use JDBC proxy like P6Spy or datasource-proxy.
P6Spy allows intercepting by either decorating DataSource
or stub JDBC Driver (requires no code changes) and prints logs in format:
p6spy: #1617156635 | took 0ms | statement | connection 3|SELECT NOW()
Datasource-proxy only supports decorating DataSource
and prints:
n.t.d.l.l.SLF4JQueryLoggingListener:
Name:, Time:0, Success:True
Type:Statement, Batch:False, QuerySize:1, BatchSize:0
Query:["SELECT NOW()"]
Params:[]
Upvotes: 0