-
-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Provide a way to log interactions with database #1815
Comments
Have you come across https://jdbi.org/#_sqllogger ? |
I've read about |
Well, for jdbi to provide an impl, we'd need to provide a separate module or a runtime dependency on all the big logger frameworks, though I can't remember more than slf4j and log4j atm. Either that or you'd pass a factory like I just had a look at the logger in my pet project and I do have some extensive logic in there, because I insist on a different slf4j logger instance name for SqlObjects, do Rather than us providing 1 out of infinite possible flavors of implementation that'll be debated about forever, how about a compromise in the form of a simplified interface that receives a |
In the meantime, this is exactly the impl of what I needed to debug the sql going to the database if it helps anyone else. class SqlLoggerImpl : SqlLogger {
private val logger = LoggerFactory.getLogger(this::class.java)
override fun logBeforeExecution(context: StatementContext?) {
if (logger.isDebugEnabled && context != null) {
logger.debug(context.statement.toString())
}
}
} and then when instantiating JDBI jdbi.setSqlLogger(SqlLoggerImpl()) |
We can include a simple slf4j implementation out of the box, since we already depend on that. |
I think that's all it's needed. People can hook this into their preferred logging framework via one of those available "bridges". Additionally, it would be needed to print the queries and value bindings also at some predefined logging level — |
I'm fairly new to Jdbi. I've been trying to integrate with Spring Boot and everything is going fine so far in my (very basic) tests.
What I haven't been able to find is a way to log the interactions with the database — namely the same result one can achieve when turning Hibernate's
show-sql
totrue
.I haven't find a way to visualize this, so I was expecting a (set of) configuration setting(s), or something like increasing the log level on certain namespace(s), etc.
Obligatory StackOverflow question: https://stackoverflow.com/questions/66431905/log-jdbi-interactions-with-database
The text was updated successfully, but these errors were encountered: