Log4J2 Logging in Java framework Selenium test automation
>> YOUR LINK HERE: ___ http://youtube.com/watch?v=WX8q5VWkpaY
In this video we will discus about logging in automation framework. There are many number of logging libraries available, which can be use in our framework. But in our framework we are going to use Apache Log4j2. • Different Log events we can use in Log4j2are as below: • ERROR • WARN • INFO • DEBUG • VERBOSE • If we want to use Log4j in our framework, then below dependency has to be added in pom.xml file. • dependency • groupIdorg.apache.logging.log4j /groupId • artifactId log4j-core /artifactId • version 2.13.3 /version • /dependency • To initialize the logger in class you can write the below code. • Logger log = (Logger) LogManager.getLogger(stepdef.class); • Then you can use the log object to generate logs. • log.info( Navigated to url +url); • Apart from this we have to add below log4j2.xml in our project root folder. • Based on the minimum log event type, provided in the configuration we will get the log events in the log file. • #?xml version= 1.0 encoding= UTF-8 ?# • #Configuration status= WARN strict= true # • #Properties# • #Property name= filename #C:/Project/SeleniumJunit/automation/Results/Logs.log#/Property# • #/Properties# • #Appenders# • #Appender type= Console name= STDOUT # • #Layout type= PatternLayout pattern= %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n /# • • #/Appender# • #Appender type= File name= File fileName= ${filename} # • #Layout type= PatternLayout pattern= %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n /# • • #/Appender# • #/Appenders# • • #Loggers# • • #Root level= info # • #AppenderRef ref= File /# • #/Root# • #/Loggers# • • #/Configuration# • • Please comment in case of any queries. • • Also please see my other videos as well. • Schedule a job with Jenkins | Build Periodically in Jenkins | Cron string syntax: • #2 Jenkins Integration | Schedule a j... • Jenkins Integration : • #1 Jenkins integration | Selenium fra... • Add Java properties configuration file in framework - Selenium Java - • Configuration file in automation fram... • Parallel execution of cucumber scenario TestNG : • Parallel Execution of Cucumber Scenar... • Log4J2 - Logging in Java Framework : • Video • Selenium with Java - Create Junit Cucumber Project : • Video • Selenium - Debug/Run Script on Existing Browser : • Selenium | Debug/Run Script on Existi... • Selenium with Java - Extent Report - Part1 : • Selenium with Java | Extent Report 5 ... • Selenium - WebDriver Manager : • Selenium | WebDriver Manager | Stop d... • Parallel Execution - Cucumber - Junit : • Parallel Execution | Cucumber | Junit • Selenium with Java - Cucumber Html Report : • Selenium with Java | Cucumber Html Re... • Selenium with Java - Integrate TestNG with Cucumber - • Video • Selenium with C# - Klov Report : • Selenium with C# | Klov Report Server • Selenium with C# - Extent Report : • Selenium with C# | Extent Report • Selenium with C# - Create Project to automate test (Selenium + Specflow ) : • Video • Selenium with C# - Parallel Execution and Screenshot : • Video • Selenium with C# - All about feature files : • Video • Selenium with C# - Specflow - External Bindings : • Selenium C# | Specflow | External Bin... • Selenium with C# Working with Excel - Part 1 : • #1 Working with Excel | Selenium C# |... • Selenium C# - Visual Studio Code : • Selenium C# | Visual Studio Code | No...
#############################
