Posts

Selenium Integration with Maven & TestNG

Terminologies - Log4J - Components of Logging API & Process Flow

Image
  3 Core Components of Java logging API  Loggers are responsible for capturing events (called LogRecords) and passing them to the appropriate Appender. Appenders (also called Handlers in some logging frameworks) are responsible for recording log events to a destination. Appenders use Layouts to format events before sending them to an output. Layouts (also called Formatters in some logging frameworks) are responsible for converting and formatting the data in a log event. Layouts determine how the data looks when it appears in a log entry. Process Flow: When your application makes a logging call, the Logger records the event in a LogRecord and forwards it to the appropriate Appender.  The Appender then formats the record using a Layout before sending it a destination such as the console, a file, or another application.  Additionally, you can use one or more Filters to specify which Appenders should be used for which events. Filters aren’t required, but they give you gr...

Technologies - Log4J - Create Log4j Configuration File - Where ? How ? What ?

  Typical Steps involved in Creating Log4j Configuration file Configure the root logger - What to Log - info/debug/error/fatal messages Configure individual loggers (if needed). Specify appenders -- Where to Log -- in File/Console, etc Specify message layout/Pattern -- How to Log - format to log the message Configuring a Layout PatternLayout lets you determine how data is extracted from log events and formatted for output based on a conversion pattern. Conversion patterns act as placeholders for data that appears in each log event.  For example, let’s break down a PatternLayout commonly used in Log4j: <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> %d{HH:mm:ss.SSS} formats the date in terms of hours, minutes, seconds, and milliseconds. %t displays the Logger’s current thread. %level displays the severity of the log event. %logger displays the name of the Logger. %m displays the event’s message. Finally, %n adds a new line for the next e...

Technologies - Log4J - Initializing Logging

Initializing Logging mechanism using Log4J  package com.SeleniumPractise; import org.apache.logging.log4j.*; public class Demo { private static Logger log = LogManager.getLogger(Demo.class.getName()); public static void main(String[] args) { log.debug("Logging a debug message"); log.info("Logging info level"); log.error("Logging Error message"); log.fatal("Fatal error message"); } }

Technologies - Log4J - Download, Eclipse Integration and Usage

Download -  https://www.apache.org/dyn/closer.lua/logging/log4j/2.14.1/apache-log4j-2.14.1-bin.zip Usage  Logs the success action events - successful button click, select checkbox/radio button, etc. Logs failures or exceptions Logs the events with date and timestamp & many more  Only 2 jars are required for our purpose - log4j-api-2.14.1, log4j-core-2.14.1 Eclipse  Extract the Log4j Zip file Navigate to Build path in project Select External Jar files and select the extracted path - then select  log4j-api-2.14.1 & log4j-core-2.14.1 file alone.

Technologies - TestNG Framework - XML File

Technologies - TestNG Framework - Assertions (TBD)