2015-09-05 40 views
1

我m到處錯誤消息Log4j屬性給錯誤

log4j:WARN No appenders could be found for logger (com.faktorZehn.socialNetwork.socialNetwork.PersonGenerator). 
log4j:WARN Please initialize the log4j system properly. 
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 

enter image description here

我的屬性看起來像

This sets the global logging level and specifies the appenders 
log4j.rootLogger=INFO, theConsoleAppender 

# settings for the console appender 
log4j.appender.theConsoleAppender=org.apache.log4j.ConsoleAppender 
log4j.appender.theConsoleAppender.layout=org.apache.log4j.PatternLayout 
log4j.appender.theConsoleAppender.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n 

我在哪裏做錯了任何的IDE?

回答

3

您的資源文件夾不在您的類路徑中。右鍵點擊文件夾 - > Build Path - >用作源文件夾。

然後重新運行您的應用程序,log4j.properties應該由log4j框架使用。

1

確保log4j.properties位於類路徑中。 使resources文件夾實際上是一個資源文件夾。它看起來像一個maven項目,所以你可以將它移動到src/main/resources

或者,你可以使用JVM參數來設置它。

-Dlog4j.configuration=resources/log4j.properties