1

We are using Hikari connection pool for database connection management in our application. We have configured Hikari CP as a resource in tomcat server.xml. Now due to some issue with HIKARI we require DEBUG level logs generated from HIKARI library. I tried configuring package level logger in conf\log4j.properties, but I am unable to see logs from HIKARI library. Is there any different configuration for logging from libraries used as resource in tomcat server.xml?

Below lines are added in log4j.properties file in conf directory.

log4j.logger.com.zaxxer.hikari=DEBUG,CONSOLE
log4j.additivity.com.zaxxer.hikari=true

Hikari resource configuration in server.xml.

<Resource name="jdbc/abc" auth="Container"
 factory="com.zaxxer.hikari.HikariJNDIFactory"
 type="javax.sql.DataSource"
 minimumIdle="5" 
 maximumPoolSize="100"
 connectionTimeout="300000"
 registerMbeans="true"
 driverClassName="net.sourceforge.jtds.jdbc.Driver"
 jdbcUrl="jdbc:jtds:sqlserver://localhost:1433;databaseName=testdb;domain=dev;sendStringParametersAsUnicode=false;prepareSQL=3"  
 dataSource.implicitCachingEnabled="true"
 dataSource.user=""
 dataSource.password=""  
 connectionTestQuery="Select 1" />

Thanks!

Vyas
  • 75
  • 5
  • 1
    Are you certain that the library is using log4j to log? – duffymo Oct 09 '15 at 11:59
  • @duffymo the library seems to be using slf4j, so if Vyas uses slf4j over log4j it should be fine afaik. – Jiri Tousek Oct 09 '15 at 12:05
  • I have both sl4j(slf4j-api-1.7.2.jar) and log4j(log4j-1.2.14.jar) libraries available in tomcat lib folder. I am not sure which exactly tomcat use internally. – Vyas Oct 09 '15 at 12:11
  • If Tomcat uses Log4j (Tomcat uses [JUL by default](https://tomcat.apache.org/tomcat-7.0-doc/logging.html)), you also need the [slf4j-log4j12](http://stackoverflow.com/a/24644066/3080094) jar-file in the Tomcat lib-folder. – vanOekel Oct 09 '15 at 15:14
  • Thanks vanOekel. You are correct. I forgot to add this jar file earlier. My bad. – Vyas Oct 09 '15 at 15:40

1 Answers1

0

1 remove console from logging.level.com.zaxxer.hikari=DEBUG 2 and remove additivity line

Nitin
  • 1,582
  • 11
  • 12