java - How to configure log4j2 to log for HikariCP -
i have written small gradle project can learn how configure hikaricp , jdbc , log4j2 in same project. have placed below log4j2 config in src/main/resources
directory in project. when execute project using gradle run
warning not configuring appender com.zaxxer.hikari.hikariconfig
logger.
would 1 kindly tell me doing wrong?
log4j2.xml
<?xml version="1.0" encoding="utf-8"?> <configuration status="warn"> <appenders> <console name="console" target="system_out"> <patternlayout pattern="%d{hh:mm:ss.sss} [%t] %-5level %logger{36} - %msg%n"/> </console> </appenders> <loggers> <logger name="com.zaxxer.hikari.hikariconfig" level="trace"> <appenderref ref="console"/> </logger> <root level="trace"> <appenderref ref="console"/> </root> </loggers> </configuration>
build.gradle
apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'maven' apply plugin: 'application' targetcompatibility = 1.8 sourcecompatibility = 1.8 version = '0.0.1.0' group = 'com.s2d' mainclassname = "com.s2d.jdbctest.demojdbc" applicationdefaultjvmargs = ["-djdbc.drivers=org.apache.derby.jdbc.embeddeddriver"] task wrapper(type: wrapper) { gradleversion = '1.4' } repositories { mavencentral() } dependencies { compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.0.2' compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0.2' compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.10' compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.10' compile group: 'com.zaxxer', name: 'hikaricp', version: '2.3.7' runtime group: 'org.apache.derby', name: 'derby', version: '10.11.1.1' testcompile group: 'junit', name: 'junit', version: '4.11' } test.scanfortestclasses(false) javadoc.options.links("http://docs.oracle.com/javase/7/docs/api/") task sourcesjar(type: jar, dependson: classes) { classifier = 'sources' sourcesets.main.allsource } task javadocjar(type: jar, dependson: javadoc) { classifier = 'javadoc' javadoc.destinationdir } artifacts { archives sourcesjar archives javadocjar }
execution output
[sts] ----------------------------------------------------- [sts] starting gradle build following tasks: [sts] run [sts] ----------------------------------------------------- :compilejava up-to-date :processresources :classes :run 20:27:11.247 [main] info com.s2d.jdbctest.demojdbc - starting demo log4j:warn no appenders found logger (com.zaxxer.hikari.hikariconfig). log4j:warn please initialize log4j system properly. log4j:warn see http://logging.apache.org/log4j/1.2/faq.html#noconfig more info. column count: 1 column 1 name: 1 type: decimal inserted id: 1005 20:27:12.350 [main] info com.s2d.jdbctest.demojdbc - demo complete build successful total time: 2.017 secs [sts] ----------------------------------------------------- [sts] build finished succesfully! [sts] time taken: 0 min, 2 sec [sts] -----------------------------------------------------
you're using slf4j-log4j12, allows using slf4j log messages log4j 1.2. goal log messages using slf4j on log4j 2.0.2. need binding library: https://logging.apache.org/log4j/2.0/log4j-slf4j-impl/index.html.
the maven coordinates of binding library in log4j2 documentation.
Comments
Post a Comment