[英]log4j:WARN Please initialize the log4j system properly
I am trying to learn selenium. 我正在尝试学习硒。
I get following error message: 我收到以下错误消息:
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies). log4j:WARN找不到记录器的附加程序(org.apache.http.client.protocol.RequestAddCookies)。 log4j:WARN Please initialize the log4j system properly. log4j:WARN请正确初始化log4j系统。 log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. log4j:WARN有关更多信息,请参见http://logging.apache.org/log4j/1.2/faq.html#noconfig 。
So, I have downloaded the file log4j.properties
and I have googled on it and tried to implement the file in different ways in Eclipse but nothing worked out. 因此,我下载了log4j.properties
文件,并在google上进行了搜索,并尝试在Eclipse中以不同的方式实现该文件,但没有任何结果。 I see that someone is saying: 我看到有人在说:
Put a file named log4j.properties in the root of your classpath: 在类路径的根目录中放置一个名为log4j.properties的文件:
log4j.rootLogger = ALL, Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.conversionPattern=%m%n
Nothing else is needed. 不需要什么了。 Log4j will discover it and configure itself. Log4j将发现它并进行自我配置。
But what do they mean by " in the root of your classpath "? 但是,“ 在类路径的根中 ”是什么意思?
I work in Eclipse. 我在Eclipse中工作。 So how do I find the root of the classpath in Eclipse? 那么,如何在Eclipse中找到类路径的根?
It looks like you need to add the location of your log4j.properties or log4j.xml file to the Classpath in Eclipse. 看来您需要将log4j.properties或log4j.xml文件的位置添加到Eclipse中的Classpath。
Make sure your project is open in Eclipse, then click on the "Run" menu at the top of Eclipse and click on the following: 确保您的项目在Eclipse中打开,然后单击Eclipse顶部的“运行”菜单,然后单击以下内容:
Run -> Run Configurations -> Classpath (tab) -> User Entries -> Advanced (button on the right) -> Add Folders ->then navigate to the folder that contains your log4j.properties file 运行->运行配置->类路径(选项卡)->用户条目->高级(右侧按钮)->添加文件夹->然后导航到包含log4j.properties文件的文件夹
Apply -> Run 应用->运行
The error message should no longer appear. 错误消息应该不再出现。
Did you simply try to put it in your source folder? 您是否只是尝试将其放在源文件夹中? It should be copied automatically to your deployment folder on build. 它应该自动复制到构建时的部署文件夹中。 If you already tried, it may be your deployment rules that skip *.properties files... 如果您已经尝试过,则可能是跳过* .properties文件的部署规则...
Hope that will help you 希望对您有帮助
Delete the log4j.rar from your external Libraries 从您的外部库中删除log4j.rar
steps: Right click on src-->BuildPath-->Configure Buildpath-->Libraries-->Select Log4j.rar and Remove it. 步骤:右键单击src-> BuildPath-> Configure Buildpath-> Libraries->选择Log4j.rar并将其删除。
For report generation, you need to add log4j for simply executing the script no need to add log4j. 为了生成报告,您只需添加log4j即可执行脚本,而无需添加log4j。
Hope this will solve your problem 希望这能解决您的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.