Disable HikariPool logging

后端 未结 4 722
被撕碎了的回忆
被撕碎了的回忆 2021-02-18 19:20

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         


        
相关标签:
4条回答
  • 2021-02-18 19:45

    I use log4j properties, simple add these two lines:

    log4j.category.com.zaxxer.hikari=INFO
    log4j.logger.HikariPool=INFO
    
    0 讨论(0)
  • 2021-02-18 19:58

    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>
    
    0 讨论(0)
  • 2021-02-18 19:58

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

    0 讨论(0)
  • 2021-02-18 20:01

    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

    0 讨论(0)
提交回复
热议问题