-
Notifications
You must be signed in to change notification settings - Fork 3k
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
SQL logging #57
Comments
As documented on the project page: Log Statement Text / Slow Query Logging In summary, we are unlikely to implement this feature as it impacts performance even when logging is turned off. |
:( |
Even checking a boolean flag for whether logging is enabled or disabled is too much overhead for HikariCP. Almost every driver supports logging of some sort, and ORMs inevitably do. Alternatively, use BoneCP in development and HikariCP in production. And if you need logging at the SQL statement level in production, you don't need the performance of HikariCP because logging is a performance killer. |
I am sure you would be able to solve this without performance impact - with a logging/non logging strategy pattern or something similar. Sure there are other ways to log SQL, but we support more than one database vendor, and use single point logging configuration through logback, which would by difficult with custom driver logging. |
I would also love to see such a feature within HikariCP. |
+1; Eventhou mysql server does this as well. I would like to be able to be enabled logging just for testing and dev deployes. Changing my.cfg and restarting DB server is extremely cumbersome. |
+1 for having this. How does it affect performance when turned off? I can't imagine that. |
I have been using HikariCP for close to two years and I have never needed this feature. SQL logging doesn't belong in the connection pool. I use JOOQ with HikariCP and JOOQ provides all the custom logging I need for dev / local. I am sure Hibernate / JPA / JDBI offer similar features. HikariCP is a very high performance connection pool. All logging related to pooling connections is readily available. It is not a one stop shop tool for profiling your database and making your life easier. It does one thing very well and that is all it should do. |
@billoneil I want to hug you, or buy you a beer. |
@brettwooldridge Do you have any experience combining jdbcdslog and hikaricp (or any other logging framework). Something that is generic and can be centralized (at the moment we have several datasources and a mix of mybatis and hibernate jpa). Because of that, I don't want to bother with driver specific logging or dao framework specific logging). We instantiate HikariDataSource(HikariConfig). Should I wrap the HikariDatasource in an jdbclog ConnectionPoolDataSourceProxy? Any code examples/experiences you have if you have are welcome (or maybe documented on one of your awesome wiki pages). |
@slyoldfox Did you manage to solve that? |
@balizeiro no I haven't looked further into it how I would incorporate some framework into our framework. If i do, I'll share it. If @brettwooldridge has any smart experiences, I hope he shares them :) We mixed javamelody at one point, but it seemed that activates itself when it's in the classpath, which is a designed decision by the programmer, however I'd like something that can be switched on an off if feasible and of course with not too much overhead (and yes I do know that any kind of such monitoring will have performance impact). |
We also weren't able to find sufficient replacement for deprecated JDBC's logging. @brettwooldridge I understand your point and I love your determinism and pride you take in keeping Hikary efficient, but I would still urge you to reconcider. I would argue that modern CPUs have high quality jump predictions built in, and last time I checked I wasn't able to measure time cost of an if clause. (I worked for high-frequency trading shop). Even if there was a time penalty, If you look at how long a DB query is going to take, an extra 20-30 ns to check a logger flag will be absolutely negligible. |
@patrik7 What detail level of logging are you looking for? |
Thanks Brett, the SQL statements that are going out to DB would be great. Specifically: select, update, delete, etc. I am not sure if transaction boundaries: open and commit make sense. That would only be usefull if we could somehow match them to the previously mentioned statements. Let's keep it simple. |
@patrik7 What about logging |
Is there some reason log4jdbc is inadequate here? When I needed to see the statements my driver was producing, I used that and it worked well. |
@ams2990 Thanks for that project ref, I wasn't aware of it. I've added it to the main project page. |
@ams2990 I also wasn't aware of it, if we decide to close this ticket again I would definitelly give it a try. @brettwooldridge The statement parameters are definitelly useful. I would log at DEBUG or TRACE, It will be heavy. |
@patrik7 @ams2990 We will have to consider it, but it may be worth it to invest development effort in log4jdbc, rather than recreating the same functionality in HikariCP. It looks like they have a lot of open issues, and little activity since 2012 if their release log is to be believed. |
Just for the sake of discussion (not really because I think this needs to be pushed in HikariCP). We have always worked with the following:
|
@slyoldfox I'm starting a page on JDBC Logging. Looking at some of what you guys are upto above, have you looked at log4jdbc-log4j2? It seems to support logging at different levels (WARN or ERROR) based on query execution time. Not sure on the MDC. It allows a user-defined logging adapter, which may also afford some extensibility. Just thought it was interesting. |
It is, I did not try going down to the driver level, but rather up to the eBean level which was very cumbersome. I will give it a try. Thanks! |
@brettwooldridge We have successfully used log4jdbc-log4j2 with mysql JDBC driver within Play 2.4 application. The setup was far from intuitive, but it does what it's supposed to. Thanks for your help. I don't think we need to change HikariCP. |
@brettwooldridge For what it's worth, I've successfully used https://github.com/p6spy/p6spy multiple times, and it seems to be (slightly) better maintained than log4jdbc-log4j2. At least there are consistent, recent commits. I installed it as follows:
That's it. Easy peasy. |
@cowwoc Thanks for the feedback! I updated the main project page with a link to your comment above. |
I can confirm that what @cowwoc is working with MySQL and p6spy too: The only tweak in MySQL is that you need to provide the jdbcUrl and driverClassName too. XML spring based configuration:
|
Please add sql operations logging (insert, delete, update, select) like in bonecp
The text was updated successfully, but these errors were encountered: