Login

Lost your password?
Don't have an account? Sign Up

Must Know JAVA concepts | Selenium Automation | PART – 5 | Log4j | Indepth & Complete tutorial

Logging is one of the essential concepts for any application development or testing process. For Selenium automation also, we have to log the necessary information into a file or database or any other storage medium.

Jars Download link:

Properties file content reference:

Conversion pattern explanation:

XML file content reference:

What will we learn in this video:
—————————————————
1. What is logging?
2. Why do we need a logger?
3. How can we achieve logging in Java?
4. Log4j Components
5. Priority Levels
6. Different ways to configure log4j

1. What is logging?
Logging is the process of writing log messages during the execution of a program to a central place.

2. Why do we need Logs?
If we use SOP (System.out.print()) statements to print log messages We can print log messages on the console only. So, when the console is closed, we will lose all of those logs.

3. Log4j Components
a)Logger
b)Appender
c)Layout

4. Log4j priority levels:
debug, info, warn, error, fatal

5. Different ways to configure log4j:
a) Basic configurator
b) Property File Configurator
c) XML configurator (DOMConfigurator)

#LearnAutomationOnline #Java #Log4j #InDepth #50thVideo

Best way to reach me (replies will be faster): YouTube comment section
Also, you can follow me on Facebook and Instagram.
Facebook:
Instagram:

https://www.educational.guru

37 comments

  1. Jai kumar

    Seriously superb explanation, I’m following your java and automation videos really awesome. I have never seen this type of explanation and Its very depth and really helpful for understanding the concepts.

  2. sridevi suresh

    Arul, is it possible to provide the log4j XML tags in the same XML sheet where we run our test cases from and for the Properties configurator also, where we have the config.properties file?

  3. VK knocks

    Hi Arul, Video on Log4J was really good. I need a clarification as I was tying to implement the concept in my project. Project is a MAVEN project and i have added the dependencies “org.apache.logging.log4j” with version 2.14.0 . File getting imported is “import org.apache.logging.log4j.Logger”. and when I am getting an error on this statement —> static Logger logger = Logger.getLogger(Propertylog4jExample.Class); I am getting a compile time error on Propertylog4jExample.Class. Could you please help me on this.

  4. Manikandan Km

    Hi Bro ,

    When i execute the program , i am getting the below error .

    ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

    I am not sure why it is looking for log4j2 configuration file – the filename which i dont have

    1. Manikandan Km

      @Learn Automation Online No output and Program is not executing further , No log file generation in the specified path . I am getting this exception . I have log4j.properties as well with the contents given by you

  5. Elakya D

    I executed the Properties file concept, no exception is coming the log is successfully created, but the details are missing the pattern is missing, only the messages are displaying. Can you say why?

    1. Learn Automation Online

      Make sure the patter you have given in the property file is correct. May be the pattern changed now. Search in Google and try out different patterns to see if something is changing .

  6. ALWIN 0204

    bro error method epdi use panuvom
    ippo namaku oru process nadakidhu but adhu vandhu wrong way agidhu na adhe ippo sout le if else use panni “is wrong” ne solre mari namme logger.error (“is error/wrong”) nu sollellame edi ellam use panikelama pls reply

    1. ALWIN 0204

      @Learn Automation Online bro ok bro is clear but production le dhan kekeran
      ippo informations kudakaradhu epdinu soninge framework run agumbo
      Adhu mari oru logger.error : endhe mari use panuvom

      Eg: ippo framework run panni pathitu any errors irendha then namme inge error irekenu define panuvomaa
      Using. Logger.error(“error in login page “)idhu mari

      Pls reply bro
      You can say any small eg bro ……

  7. ramesh kannan

    Hi Arul ! Thanks for this Log4j video. I was searching this content in many you tube videos and finally a got a full stuff ( Like full meals 🙂 ). Please keep up your good work. – Ramesh Kannan

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*