ERROR StatusLogger Log4j2 could not find a logging implementation.


今天在學習structs2  2.5.5的版本的時候碰到2個問題。第一個網上下的包里面差log4j-core這個包。

雖然程序可以運行,但控制台會報這個錯誤。

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

在添加了這個包后在再次運行程序。

控制台提示

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

找不到log4j2的配置文件

網上google之。找到文檔。原來只要在classpath下的目錄添加一個log4j2.xml。就可以了

 

 1 <?xml version="1.0" encoding="UTF-8"?>  
 2 <Configuration status="warn">  
 3             <Appenders>  
 4                         <Console name="Console" target="SYSTEM_OUT">  
 5                                     <PatternLayout pattern="[%-5p] %d %c - %m%n" />  
 6                         </Console>  
 7                         <File name="File" fileName="dist/my.log">  
 8                                     <PatternLayout pattern="%m%n" />  
 9                         </File>  
10             </Appenders>  
11   
12             <Loggers>  
13                         <Logger name="mh.sample2.Log4jTest2" level="INFO">  
14                                     <AppenderRef ref="File" />  
15                         </Logger>  
16                         <Root level="INFO">  
17                                     <AppenderRef ref="Console" />  
18                         </Root>  
19             </Loggers>  
20 </Configuration>

這里為什么這樣配置就不說了,可以去查閱log4j2的文檔。

在次運行程序,控制台沒有錯誤提示了

原文:http://xtceetg.blog.51cto.com/5086648/1877001


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM