Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用log4j2通用日志桥_Java_Logging_Log4j_Apache Commons_Log4j2 - Fatal编程技术网

Java 如何使用log4j2通用日志桥

Java 如何使用log4j2通用日志桥,java,logging,log4j,apache-commons,log4j2,Java,Logging,Log4j,Apache Commons,Log4j2,我想在Commons 1.2中使用log4j2 Commons日志桥。我试着使用以下方法: import org.apache.logging.log4j.jcl.LogFactoryImpl; public class MyClass{ private static Log log = LogFactoryImpl.getLog(DropinsBundleDeployer.class); . . . log.error(

我想在Commons 1.2中使用log4j2 Commons日志桥。我试着使用以下方法:

import org.apache.logging.log4j.jcl.LogFactoryImpl;

public class MyClass{

    private static Log log = LogFactoryImpl.getLog(DropinsBundleDeployer.class);
         .
         .
         .
    log.error("Error occured", e);
}
但是,当我运行代码时,我遇到以下问题,无法看到任何日志:

log4j:WARN Please initialize the log4j system properly.
但是,log4j2.xml文件位于类路径中。
如何将commons logging 1.2与log4j2一起正确使用?

您可能需要查看上的常见问题页面

类路径上需要以下JAR:

  • log4j-api-2.2
  • log4j-core-2.2
  • log4j-jcl-2.2
  • 公用记录

另外,请确保log4j-1.2不在类路径中。错误消息看起来像是log4j-1.2错误…

如果我使用log4j-jcl-2.2,我还需要有commons日志jar吗?或者只使用jcl桥就足够了?您需要commons日志jar和log4j jcl桥jar。@Remkopma感谢您的回答。一直在搜索,搜索,搜索…为什么一个使用Commons日志的库在升级到Log4jv2时停止输出日志数据。