Selenium WebDriver Data Driven Framework - Implement Logging Using Log4j

Data driven framework for selenium webdriver software testing tool must have facility to Insert test execution log to track the execution process, debugging and failures after completion of software test. Test execution logs will helps you to track your software test execution steps. In STEP 17, We have successfully reported test cases results In excel file. Now let us Implement log generation function In our selenium webdriver software automation testing framework.


Prerequisite : Previous all 17 steps of selenium webdriver data driven framework creation should be Implemented. You will find the links for all previous steps on THIS PAGE.

For log generation, We will use Apache Log4j Logging service. It Is very good service to generate test execution log for our selenium webdriver data driven framework project.

How To Generate Log
As you know, We have already added required Apache Log4j software Logging service jar file "log4j-1.2.17.jar" In our project's build path during webdriver framework creation STEP 3 and STEP 4. If you have not followed those steps then please do so. So now you are ready to use Apache Log4j Logging service.

Now, You have to add "" file under "src" folder of your project. "" file contains all the settings for log generation. I have prepared "" file with all the required settings to generate the test execution log.

Also you have to create "applog.log" file under "com.stta.Logging" package to store the execution log.

Download Required Files To Enable Logging
As described above, you need "" and "applog.log" files to generate and store execution log. 
  • I have created "" file and set all required properties to generate execution log.
  • I have created "applog.log" file. "applog.log" file Is just blank file to store log In It.
  • I have Implemented sample Logs In "", "" and "" files to explain you how to generate test execution log. 
  • Right now, I have Implemented test execution log only In "" test case. Based on that, You can Implement test execution log In all other test cases too by your self.
Download bellow given zip folder to get all above required files for log generation.
Extract the folder and copy-paste files as described bellow.
  • Paste File on "src" folder of "WDDF" project.
  • Paste applog.log File on com.stta.Logging Package.
  • Paste File on com.stta.TestSuiteBase Package.
  • Paste File on com.stta.SuiteOne Package.
  • Paste File on com.stta.SuiteOne Package.
Note : Do not change any thing "" file.
Now your selenium webdriver data driven framework project's structure will look like bellow.

Running Test To Generate Execution Log
Now we are ready to run our software test suites to verify that execution log Is generated as expected or not. Run your test suites using testng.xml file.

On completion of test execution, execution log will be generated and stored Inside applog.log file. If you will open applog.log file, It will looks like bellow.

Note : Above log Is only for "", "" and "" files. You can Implement log In all your test cases In same way. You can use bellow given syntax to Insert log In any test case or suite files."Your Log Text");

So we have successfully Implemented test execution log generation function In our selenium automation framework, And now our selenium software test data driven framework Is able to generate test execution log.


  1. I am not able to generate the logs. I am getting error File. I disabled by selecting "N" in SuiteOne.xls file still File is getting executed.

    I am able to do all steps except Step 18. Please help me in fixing this.

  2. I am not able to generate logs in applog.log file


  3. I am getting below error after implementing log4j

    log4j:WARN No appenders could be found for logger (rootLogger).
    log4j:WARN Please initialize the log4j system properly.
    I am not able to generate log file .
    any help

  4. add this line

    Add_Log = Logger.getLogger("rootLogger");


    1. No logs are generated in applog file even after adding this.

    2. PropertyConfigurator.configure("C:\\"); //provide the complete path for log4j properties file
      Yuou find the line "log4j.appender.R.Append=false" in file in line 10 and change it to true

  5. Hi Arvind,

    No new logs are appended after we follow the instruction on your page.


  6. Everything worked perfectly till step 18... thanks for this tutorial..
    would appreciate if a detailed explanation of workflow is published..