24

This is perhaps a very simple question. How do i disable Hikari-CP debug logs? In my log file i have lots of these messages

DEBUG [.zaxxer.hikari.pool.HikariPool:] - Before cleanup pool stats HikariPool-0 (total=10, inUse=0, avail=10, waiting=0)
DEBUG [.zaxxer.hikari.pool.HikariPool:] - After cleanup pool stats HikariPool-0 (total=10, inUse=0, avail=10, waiting=0)

and in my log4jConfig.xml:

<logger name="org.zaxxer.hikari">
    <level value="error"/>
</logger>

Can someone please tell me what is wrong with the logger configuration?

Thanks!

4

4 回答 4

23

The logger name should be com.zaxxer.hikari not org.zaxxer.hikari.

于 2014-12-03T14:57:29.297 回答
3

The class name is displaying in you DEBUG info: DEBUG [.zaxxer.hikari.pool.HikariPool:] - ... here the class name is zaxxer.hikari.pool.HikariPool, Just modify config file as being disaplayed.

I use logback logger, there is a file named logback.xml located in resources folder, to disable HikariPool logging, i write following config:

 <configuration>
...
    <logger name="com.zaxxer.hikari.pool.PoolBase" level="ERROR"/>
    <logger name="com.zaxxer.hikari.pool.HikariPool" level="ERROR"/>
    <logger name="com.zaxxer.hikari.HikariDataSource" level="ERROR"/>
</configuration>
于 2018-12-09T08:03:15.140 回答
1

I use log4j properties, simple add these two lines:

log4j.category.com.zaxxer.hikari=INFO
log4j.logger.HikariPool=INFO
于 2019-10-26T22:16:09.520 回答
0

You can set the levels of Hikari loggers dynamically:

import org.apache.log4j.Logger;
import org.apache.log4j.Level;

public class App{
     public static main(String[] args) {
         Logger.getLogger("com.zaxxer.hikari.pool.PoolBase").setLevel(Level.OFF);
         Logger.getLogger("com.zaxxer.hikari.pool.HikariPool").setLevel(Level.OFF);
         Logger.getLogger("com.zaxxer.hikari.HikariDataSource").setLevel(Level.OFF);
         Logger.getLogger("com.zaxxer.hikari.HikariConfig").setLevel(Level.OFF);
         Logger.getLogger("com.zaxxer.hikari.util.DriverDataSource").setLevel(Level.OFF);
     }
}

I have tested this on hikariCP 3.4.1 with log4j 1.2.17

于 2019-12-07T08:20:49.453 回答