Currently, HikariCP is logging at level INFO
and I want to set it to SEVERE
. When I try to set the level on the parent logger (the only reference to logging I can find) it throws the error:
dataSource.getParentLogger().setLevel( Level.SEVERE );
The error:
Caused by: java.sql.SQLFeatureNotSupportedException
at com.zaxxer.hikari.HikariDataSource.getParentLogger(HikariDataSource.java:176)
How do I properly set the logging level?
HikariCP uses slf4j under the hood. You will have to set the log level on your actual logger implementation ( logback , log4j , JUL , ...).
Also, slf4j provides a very simple logger implementation slf4j-simple . Just add the dependency to your pom
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
</dependency>
You can then configure it using system properties , eg
java -Dorg.slf4j.simpleLogger.log.com.zaxxer.hikari=error ...
Another way to programmatically set log level
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
ch.qos.logback.classic.Logger hikariLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("com.zaxxer.hikari");
hikariLogger.setLevel(Level.ERROR);
Remove theese jars from your classpath or lib directory if you have.
logback-classic.jar logback-core.jar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.