2015-09-05 39 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