i trying enable printing debugging information maven project. added log4j dependency pom.xml
, added log4j.properties
log4j2.properties
rootloger=debug, sdout
src/main/resources
folder. in desired class, initiate logger in desired class 'org.pakage1.classa' , add logger.debug()
lines nothing shown in consul. when checked logger.isdebugenabled()
returns false
pom.xml
<dependencies> ..... <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-log4j12</artifactid> <version>1.7.25</version> </dependency>
log4j.properties , log4j2
log4j.debug=true log4j.rootlogger=debug, stdout log4j.appender.stdout.threshold=debug log4j.appender.stdout=org.apache.log4j.consoleappender log4j.appender.stdout.layout=org.apache.log4j.patternlayout log4j.appender.stdout.layout.conversionpattern=%-5p %d [%t] %c{1} - %m%n
and step tried adding
log4j.logger.extendedsldnf.extendedsldnfevaluator=debug
but did not work.
package package1; ...... class classa{ private logger logger = loggerfactory.getlogger(getclass()); ...... public static void main(string []args){ logger.debug("message"); } }
knowing getting warning
slf4j: class path contains multiple slf4j bindings. slf4j: actual binding of type [ch.qos.logback.classic.util.contextselectorstaticbinder]
also project has other sub-modules have logging enabled , debugging messages works when stated in log4j.properties
file
is there missing? how check if there conflicting?
added log4j.properties log4j2.properties
the first 1 log4j 1, second 1 log4j 2. declaring both not way solve problem.
use 1 matches actual log4j version.
slf4j: class path contains multiple slf4j bindings. slf4j: actual binding of type [ch.qos.logback.classic.util.contextselectorstaticbinder]
indeed, problem rather clear : want use log4j implementation slf4j binding but have @ runtime in classpath @ least 1 slf4j binding. here mentioned contextselectorstaticbinder
logback binding.
you have have in classpath @ runtime single implementation/binding slf4j.
to solve problem, rather simple.
use maven, propose execute mvn dependency:tree
command agreggator pom of application or if have not agreggator pom, pom packages application.
command write output dependencies (including transitive dependencies pulled pom).
it output :
[info] --- maven-dependency-plugin:2.10:tree (default-cli) @ test-spring-boot --- [info] test-spring-boot:test-spring-boot:jar:0.0.1-snapshot [info] \- org.springframework.boot:spring-boot-starter-web:jar:1.4.4.release:compile [info] +- org.springframework.boot:spring-boot-starter:jar:1.4.4.release:compile [info] | +- org.springframework.boot:spring-boot:jar:1.4.4.release:compile [info] | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.4.4.release:compile [info] | +- org.springframework.boot:spring-boot-starter-logging:jar:1.4.4.release:compile [info] | | +- ch.qos.logback:logback-classic:jar:1.1.9:compile [info] | | | +- ch.qos.logback:logback-core:jar:1.1.9:compile [info] | | | \- org.slf4j:slf4j-api:jar:1.7.22:compile [info] | | +- org.slf4j:jcl-over-slf4j:jar:1.7.22:compile [info] | | +- org.slf4j:jul-to-slf4j:jar:1.7.22:compile [info] | | \- org.slf4j:log4j-over-slf4j:jar:1.7.22:compile [info] | +- org.springframework:spring-core:jar:4.3.6.release:compile [info] | \- org.yaml:snakeyaml:jar:1.17:runtime [info] +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.4.4.release:compile [info] | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.11:compile [info] | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.11:compile [info] | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.11:compile [info] +- org.hibernate:hibernate-validator:jar:5.2.4.final:compile [info] | +- javax.validation:validation-api:jar:1.1.0.final:compile [info] | +- org.jboss.logging:jboss-logging:jar:3.3.0.final:compile [info] | \- com.fasterxml:classmate:jar:1.3.3:compile [info] +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.6:compile [info] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.6:compile [info] | \- com.fasterxml.jackson.core:jackson-core:jar:2.8.6:compile [info] +- org.springframework:spring-web:jar:4.3.6.release:compile [info] | +- org.springframework:spring-aop:jar:4.3.6.release:compile [info] | +- org.springframework:spring-beans:jar:4.3.6.release:compile [info] | \- org.springframework:spring-context:jar:4.3.6.release:compile [info] \- org.springframework:spring-webmvc:jar:4.3.6.release:compile [info] \- org.springframework:spring-expression:jar:4.3.6.release:compile
you have identify logback dependency pulled.
once having identified it, remove dependency if dependency explicitly declared our own pom.
if transitive dependency, use exclusion dependency mechanism of maven.
Comments
Post a Comment