log4j、log4j2冲突问题

2016/12 01 13:12
此文章不得转载,如有需要请联系网站管理员。

一度的温暖,一百度的爱情,来自于胜博发娱乐老虎机的点点滴滴

援用的jar里是用log4j,而我自己的项目是log4j2

当我运转的时分会报出如下错误:

log4j:WARN No appenders could be found for logger org.I0Itec.zkclient.ZkConnection.
log4j:WARN Please initialize the log4j system properly.

当我去失这个jar的时分,log4j2.xml就生效能看到日记了

怎样将这个jar的log4j,转到log4j2?

  1. zookeeper-3.4.0 之后的版本曾经运用了slf4j的日记接口,可以直接将log4j的相干依赖排撤除。

  2. 假如zookeeper3.4.0之前的版本需求对zookeeper中断晋级,反复第1步操纵

zookeeper-3.4.0


kafka_2.9.1-0.8.2.2

<dependency>
    <groupId>com.101tec</groupId>
    <artifactId>zkclient</artifactId>
    <version>0.3</version>
    <scope>compile</scope>
</dependency>

方才看了一下kafka中运用的zkclient版本比较的低,在高版本中zkclient也曾经切换至slf4j的接口了,可以将zkclient晋级一下。

<dependency>
      <groupId>org.apache.kafka</groupId>
      <artifactId>kafka_2.9.1</artifactId>
      <version>0.8.2.2</version>
      <exclusions>
          <exclusion>
               <artifactId>log4j</artifactId>
               <groupId>log4j</groupId>
          </exclusion>
     </exclusions>
</dependency>

做了打扫之后报错:

java.lang.NoClassDefFoundError: org/apache/log4j/Logger

    at org.I0Itec.zkclient.ZkClient.<clinit>ZkClient.java:57
    at sun.reflect.NativeMethodAccessorImpl.invoke0Native Method
    at sun.reflect.NativeMethodAccessorImpl.invokeNativeMethodAccessorImpl.java:57
    at sun.reflect.DelegatingMethodAccessorImpl.invokeDelegatingMethodAccessorImpl.java:43
    at java.lang.reflect.Method.invokeMethod.java:606
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCallFrameworkMethod.java:50
    at org.junit.internal.runners.model.ReflectiveCallable.runReflectiveCallable.java:12
    at org.junit.runners.model.FrameworkMethod.invokeExplosivelyFrameworkMethod.java:47
    at org.junit.internal.runners.statements.InvokeMethod.evaluateInvokeMethod.java:17
    at org.junit.runners.ParentRunner.runLeafParentRunner.java:325
    at org.junit.runners.BlockJUnit4ClassRunner.runChildBlockJUnit4ClassRunner.java:78
    at org.junit.runners.BlockJUnit4ClassRunner.runChildBlockJUnit4ClassRunner.java:57
    at org.junit.runners.ParentRunner$3.runParentRunner.java:290
    at org.junit.runners.ParentRunner$1.scheduleParentRunner.java:71
    at org.junit.runners.ParentRunner.runChildrenParentRunner.java:288
    at org.junit.runners.ParentRunner.access$000ParentRunner.java:58
    at org.junit.runners.ParentRunner$2.evaluateParentRunner.java:268
    at org.junit.runners.ParentRunner.runParentRunner.java:363
    at org.junit.runner.JUnitCore.runJUnitCore.java:137
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgsJUnit4IdeaTestRunner.java:119
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgsJUnit4IdeaTestRunner.java:42
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStartJUnitStarter.java:234
    at com.intellij.rt.execution.junit.JUnitStarter.mainJUnitStarter.java:74
    at sun.reflect.NativeMethodAccessorImpl.invoke0Native Method
    at sun.reflect.NativeMethodAccessorImpl.invokeNativeMethodAccessorImpl.java:57
    at sun.reflect.DelegatingMethodAccessorImpl.invokeDelegatingMethodAccessorImpl.java:43
    at java.lang.reflect.Method.invokeMethod.java:606
    at com.intellij.rt.execution.application.AppMain.mainAppMain.java:144
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
    at java.net.URLClassLoader$1.runURLClassLoader.java:366
    at java.net.URLClassLoader$1.runURLClassLoader.java:355
    at java.security.AccessController.doPrivilegedNative Method
    at java.net.URLClassLoader.findClassURLClassLoader.java:354
    at java.lang.ClassLoader.loadClassClassLoader.java:425
    at sun.misc.Launcher$AppClassLoader.loadClassLauncher.java:308
    at java.lang.ClassLoader.loadClassClassLoader.java:358
    ... 30 more

zookeeper 版本3.4.6

(看完/读完)这篇文章有何感想! 来看看胜博发娱乐老虎机是怎么评论的吧!

--转载请注明: sbf999胜博发老虎机_胜博发娱乐老虎机_sbf999胜博发pt娱乐老虎机 » log4j、log4j2冲突问题

发表评论

(必填)