我在tomcat 8.0.28中安装了JNDI Hikaricp 2.4.1 oracle池连接。它运作良好,但我希望看到来自Hikaricp的所有日志级别消息。现在我只看到INFO消息。我如何在tomcat中配置它。我不太了解tomcat和hikaricp日志系统的工作原理。这是我的配置:
我添加了$ CATALINA_HOME \ lib:
HikariCP-2.4.1.jar
javassist-3.20.0-GA.jar
slf4j-api-1.7.12.jar
slf4j-jdk14-1.7.12.jar
ojdbc6.jar
我添加了$ CATALINA_HOME \ conf \ server.xml:
<GlobalNamingResources>
<Resource name="jdbc/OracleHikari" auth="Container"
factory="com.zaxxer.hikari.HikariJNDIFactory"
type="javax.sql.DataSource"
maximumPoolSize="5"
connectionInitSql="SELECT 1 FROM dual"
dataSource.implicitCachingEnabled="true"
dataSource.user="xxx"
dataSource.password="yyy"
dataSourceClassName="oracle.jdbc.pool.OracleDataSource"
dataSource.url="jdbc:oracle:thin:@.... "
/>
</GlobalNamingResources>
我添加了$ CATALINA_HOME \ conf \ context.xml:
<Context>
<ResourceLink
name="jdbc/OracleHikari"
global="jdbc/OracleHikari"
type="javax.sql.DataSource"
/>
</Context>
我想我必须在$ CATALINA_HOME \ conf \ logging.properties中添加一些东西,但我不知道是什么。我测试过:
com.zaxxer.hikari.apache.juli.AsyncFileHandler.level = FINE
com.zaxxer.hikari.apache.juli.AsyncFileHandler.directory =
${catalina.base}/logs
com.zaxxer.hikari.apache.juli.AsyncFileHandler.prefix = manager.
但不起作用。
由于
答案 0 :(得分:0)
迟到的回复,但我能够通过添加您在上面指定的罐子并将以下条目添加到/conf/logging.properties来启用调试级别日志记录到catalina.out:
com.zaxxer.hikari.level = FINEST
我现在在catalina.out
中看到这样的消息 26-Apr-2016 14:49:54.312 FINE [Hikari housekeeper (pool HikariPool-0)] com.zaxxer.hikari.pool.HikariPool.logPoolState Before cleanup pool HikariPool-0 stats (total=10, active=0, idle=10, waiting=0)
26-Apr-2016 14:49:54.312 FINE [Hikari housekeeper (pool HikariPool-0)] com.zaxxer.hikari.pool.HikariPool.logPoolState After cleanup pool HikariPool-0 stats (total=10, active=0, idle=10, waiting=0)
26-Apr-2016 14:49:54.609 FINE [http-nio-8080-exec-7] com.zaxxer.hikari.pool.PoolElf.resetConnectionState HikariPool-0 - Reset (nothing) on connection com.mysql.jdbc.JDBC4Connection@78e209fb
26-Apr-2016 14:49:54.609 FINE [http-nio-8080-exec-9] com.zaxxer.hikari.pool.PoolElf.resetConnectionState HikariPool-0 - Reset (nothing) on connection com.mysql.jdbc.JDBC4Connection@491783a7
26-Apr-2016 14:49:54.613 FINE [http-nio-8080-exec-7] com.zaxxer.hikari.pool.PoolElf.resetConnectionState HikariPool-0 - Reset (nothing) on connection com.mysql.jdbc.JDBC4Connection@78e209fb
答案 1 :(得分:0)
请注意,在Tomcat版本8.5.16中,此配置的输出将写入文件:
${CATALINA_HOME}/logs/catalina.date.log
另外,上面提到的库:
javassist-3.20.0-GA.jar
不是必需的。
否则,本文中详述的配置确实有效。