Why I am getting errors on console regarding log4j system initialization

Hi, This would be my first question here. A forum like this is really appreciated.

I got my question from following post

http://www.toolsqa.com/selenium-webdriver/log4j-logging/

I followed the exact steps given here in order to enable logging for my tests. I was using TestNG for executing tests.  My questions are…

1. You mentioned about log4j.xml file only and not anything about log4j.properties file. Is that not necessary at all (I assume it is somewhat required as per http://logging.apache.org/log4j/1.2/faq.html#noconfig)? Are they same thing? I see that in code you mentioned something like

DOMConfigurator.configure(“log4j.xml”);

please advise about the differences, usage and cause of not mentioning in your tutorial.

2. When I ran tests, I immediately see errors on console as

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

I googled this and got some information (not exact but related)

http://stackoverflow.com/questions/26335815/need-to-remove-log-file-warning-in-selenium

I would be interested in knowing what may be the cause of these errors as well. Please advise for both questions.

Last, I think there is a typo in following…the  How to do it… section

1) Download JAR files of Log4j and Add Jars to your project library. You can download it from here. That’s all about configuration of Apache POI with eclipse. Now you are ready to write your test.

It should be

1) Download JAR files of Log4j and Add Jars to your project library. You can download it from here. That’s all about configuration of Log4j with eclipse. Now you are ready to write your test.

That’s it as of now.

Good work on this nice tutorial and entire ToolSQA stuff :)

Thanks
Test Analyst

TestAnalyst Default Asked on April 11, 2015 in Selenium WebDriver.
Add Comment
1 Answer(s)

This error comes if you dont have the configuration XML. Are you using one? If you are using it put it in the build path of the project.

Virender

Virender Singh Professor Answered on April 13, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.