2015-04-23 80 views
8

我想使用log4j2 Commons Logging Bridge with commons 1.2。我試着像如下使用的東西:如何使用log4j2 Commons Logging Bridge

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文件是班級路徑。 如何正確使用log4j2的commons logging 1.2?

回答

11

你可能想看看which jars you need的FAQ頁面。

您需要在classpath以下jar文件:

  • 的log4j-API 2.2
  • log4j的核心 - 2.2
  • 的log4j-JCL-2.2
  • 公共記錄

另請確保在您的類路徑中log4j-1.2是而不是。那個錯誤消息看起來像是一個log4j-1.2錯誤...

+0

如果我使用log4j-jcl-2.2仍然需要使用commons logging jar嗎?或單獨使用jcl橋樑就足夠了? – Grant

+2

你需要commons-logging jar和log4j-jcl bridge jar。 –

相關問題