Skip to content
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

Suppress warning message on connection death #70

Closed
ams2990 opened this issue Apr 30, 2014 · 5 comments
Closed

Suppress warning message on connection death #70

ams2990 opened this issue Apr 30, 2014 · 5 comments
Labels

Comments

@ams2990
Copy link
Contributor

ams2990 commented Apr 30, 2014

So I had a connection die and HikariCP threw two huge warning messages into my log. Can I either suppress these or replace them with my own message? I don't really care if a connection sitting idle in the pool died, since a new one will just take its place. The first two lines from the two stack traces are below:

2014-04-30 01:00:11 [WARN] Connection com.amshulman.insight.lib.mysql.MySQLConnection@cf5011b (HikariPool-0) marked as broken because of SQLSTATE(08), ErrorCode(-1).
java.sql.SQLNonTransientConnectionException: Could not ping: unexpected end of stream, read 0bytes from 4

2014-04-30 01:00:11 [WARN] Exception during keep alive check, that means the connection must be dead.
java.sql.SQLNonTransientConnectionException: Could not ping: unexpected end of stream, read 0bytes from 4
@brettwooldridge
Copy link
Owner

You can suppress these if you want. But you might not get these with the latest version (1.3.8), because the isConnectionAlive() test was allowing some dead connection through, when they should have been terminated before returning them to the user. But you might also want to make sure your maxLifetime in the pool is set to something slightly shorter than the idle timeout configured in your database.

@ams2990
Copy link
Contributor Author

ams2990 commented Apr 30, 2014

How do I suppress the warning messages? I didn't see a configuration setting.

@brettwooldridge
Copy link
Owner

You would do it through your logging framework. For example, in log4j (property file):

log4j.logger.com.zaxxer.hikari.proxy=ERROR

that will suppress logs that are less than ERROR (eg. WARN, INFO, DEBUG) for the classes in package com.zaxxer.hikari.proxy. Most other logging frameworks (java.util.logging) have similar configuration options.

@ams2990
Copy link
Contributor Author

ams2990 commented Apr 30, 2014

Is a dead connection the only warning HikariCP will throw?

@brettwooldridge
Copy link
Owner

The only other one is if you are using the leak detection feature. So, if you want to specifically target that message as much as possible, use:

log4j.logger.com.zaxxer.hikari.proxy.ConnectionProxy=ERROR

The leak detection is logged from another class, so would not be suppressed by that configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants