Antelop
Antelop

Reputation: 157

How to configure the pool size of a DBappender in logBack with HikariDataSource ?

This is my logback configuration with HikariDatasource :

<appender name="AUDIT-DB" class="ch.qos.logback.classic.db.DBAppender">
    <connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
        <dataSource class="com.zaxxer.hikari.HikariDataSource">
            <driverClassName>com.mysql.jdbc.Driver</driverClassName>
            <jdbcUrl>jdbc:mysql://myurl:3306/audit?useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false</jdbcUrl>
            <username>mysqlciuser</username>
            <password>mysqlcipwd</password>
        </dataSource>
    </connectionSource>
</appender>

In the documentation of logback https://logback.qos.ch/manual/appenders.html, I don't find a way to limit the default pool size(10) created by the datasource. I try to use the tag : <maxPoolSize>5</maxPoolSize> but it doesn't work.

Thanks for your help.

Upvotes: 4

Views: 1408

Answers (1)

Sergiy
Sergiy

Reputation: 2071

You should you use the following config line:

<maximumPoolSize>50</maximumPoolSize>

The issue is that setter and field name are contradicting in HikariConfig:

 @Override
   public void setMaximumPoolSize(int maxPoolSize)
   {
      if (maxPoolSize < 1) {
         throw new IllegalArgumentException("maxPoolSize cannot be less than 1");
      }
      this.maxPoolSize = maxPoolSize;
   }

Upvotes: 6

Related Questions