Module 5: Selenium Logging - How to Configure log4j logging to Selenium Automation Framework?

<<< Previous Chapter

Configure log4j logging to Selenium Automation FrameworkApache Log4j logging plays a vital role in providing a fast and reliable framework coded in Java. It's an open source which fits both small scale and large scale projects. It has the ability for both File and Database logging.

Log4j has basically 3 major components: Loggers, Appenders and Layout. These components can be used as per the automation framework requirements they are being embedded in.

I would not be explaining log4j in detail in this Lockdown Special Automation Framework design series as it itself is a very lengthy topis to talk about. Let's go ahead and integrate Log4j to our framework:


Create a Log4J.xml file at root directory as we created folders yesterday.
  • This file will be used to:
  • Configure logging.
  • Configure logs storage location/Information.
  • Configure the the log file name.
  • Configure Content appender information (Display logs on console or write in a file)
  • Archive existing logs with timestamp and generate new log file for every test execution.
  • Configure Content level information that what all we need to log (Trace/error)
Now our project should look like:
 

Simply Copy below code snippet in Log4j.xml file. No need to try to understand it as of now, it's a common Log4j Logging Configuration that can be used in any project:

Hope you all are enjoying this Free Tutorial on  Learn to Design an Automation Framework from SCRATCH 

Previous Modules:
Module 0: Intro The Transformers Pledge >>> https://bit.ly/2XCokxo | Subscription Link? shorturl.at/cIM26
Module 1: Getting Started with Java and Maven Environment setup https://bit.ly/3cnOfNg
Module 2: Setup & Initialize Automation Framework >>> https://bit.ly/3ev6jqE
Module 3: Understanding and updating pom.xml >>> https://bit.ly/2VImaKe
Module 4: Designing Selenium Framework Folder Structure https://bit.ly/3eunM2x


Have a great day! Happy Testing :)

1 comment:

  1. The detailed guide makes it possible to optimize all aspects of the project in accordance with new requirements. The result of the work will be positive

    ReplyDelete

Thanks a lot for your valuable Comment!