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: bit.ly/2W5J6lK
Properties file content reference: bit.ly/2sYyGZu
Conversion pattern explanation: bit.ly/2HmemK3
XML file content reference: bit.ly/2FBJMKM
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): KZread comment section
Also, you can follow me on Facebook and Instagram.
Facebook: bit.ly/2TqPlis
Instagram: bit.ly/2Ez36rH

Пікірлер: 93

  • @rameshkannan8220
    @rameshkannan82203 жыл бұрын

    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

  • @LearnAutomationOnline

    @LearnAutomationOnline

    3 жыл бұрын

    Glad it was helpful!

  • @Jaikumar-xq8br
    @Jaikumar-xq8br2 жыл бұрын

    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.

  • @rvthym89
    @rvthym8911 ай бұрын

    Great Video and happy to know that the best content on testing is available in tamil. Keep Posting

  • @mugundhans8536
    @mugundhans85362 жыл бұрын

    dheivamae u r great plz continue to do such videos we will support u

  • @arunvikrama
    @arunvikrama2 жыл бұрын

    Excellent teaching Making new to software like me to understand concepts

  • @dhanasusila77
    @dhanasusila77 Жыл бұрын

    Excellent Explaination Arul! Thanks a lot !

  • @thechennaicook8961
    @thechennaicook89615 жыл бұрын

    Very nice explanation 😁 I was waiting for a session like this.. Keep rocking.. 😎

  • @LearnAutomationOnline

    @LearnAutomationOnline

    5 жыл бұрын

    Thanks a lot. Keep learning. 😊

  • @sethuchiyan16
    @sethuchiyan16 Жыл бұрын

    Hi Arul, good detailed info on log4j, Thank you !

  • @johnkeneddy6466
    @johnkeneddy6466 Жыл бұрын

    Clean Explanation Arul Bro 👏👏

  • @prabakarm5025
    @prabakarm50253 жыл бұрын

    Neenga yepdi debug pannuvinga In eclipse if facing issue in script Do u use log file instead of debugging

  • @BharathiManohar-fl5yi
    @BharathiManohar-fl5yi Жыл бұрын

    excellent information..thanku so much

  • @sylesh1306
    @sylesh1306 Жыл бұрын

    Thankyou for this knowledge

  • @sridevisuresh2554
    @sridevisuresh25543 жыл бұрын

    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?

  • @yesjay1335
    @yesjay13354 жыл бұрын

    Excellent explanation...

  • @sivaneshwaran8627
    @sivaneshwaran8627 Жыл бұрын

    Good work, clear explanation

  • @madhanjohn10
    @madhanjohn103 жыл бұрын

    Hi Arul, This video is very useful for me, and i executed successfully my script also

  • @LearnAutomationOnline

    @LearnAutomationOnline

    3 жыл бұрын

    Great 👍

  • @skccharan
    @skccharan Жыл бұрын

    Thank you

  • @sathishraju5749
    @sathishraju57494 жыл бұрын

    Excellent sir

  • @krishs-ms8ym
    @krishs-ms8ym11 ай бұрын

    Thank you for the tutorial

  • @sylesh1306
    @sylesh1306 Жыл бұрын

    You're the best sir..

  • @suganthi1435
    @suganthi14353 жыл бұрын

    Thank you so much for this great explanation

  • @LearnAutomationOnline

    @LearnAutomationOnline

    3 жыл бұрын

    😊

  • @benittoraja5957
    @benittoraja59572 жыл бұрын

    Thank you.

  • @srigurumurthy5754
    @srigurumurthy5754 Жыл бұрын

    great explanation bro

  • @LokeshA-nl1qu
    @LokeshA-nl1qu Жыл бұрын

    Thanks😊, You are underrated😢

  • @nareshs4631
    @nareshs46314 жыл бұрын

    Sir in this video for Basic configurator.. %x denotes?

  • @arunprashathgangatharan4689
    @arunprashathgangatharan4689 Жыл бұрын

    Hi Arul, very nice explanation, What does mean slf4j ?

  • @karthikkeyan2017
    @karthikkeyan20175 жыл бұрын

    Hi my small doubt is while using Property file we mentioned RollingFile Appender but in xml, we used File Appender but final outcome was same for both scenarios. Are both same?

  • @LearnAutomationOnline

    @LearnAutomationOnline

    5 жыл бұрын

    Almost. Different name for different implementation. Function same

  • @vkknocks3551
    @vkknocks35513 жыл бұрын

    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.

  • @kadhaikalamvaanga9824

    @kadhaikalamvaanga9824

    2 жыл бұрын

    yes bro for me to same error

  • @learnwithpraveen7536
    @learnwithpraveen75369 ай бұрын

    Some key didn't display what will I do sir

  • @manikandankm3974
    @manikandankm39744 жыл бұрын

    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

  • @LearnAutomationOnline

    @LearnAutomationOnline

    4 жыл бұрын

    Are you getting the output or u r getting the exception and the program is not proceeding further?

  • @manikandankm3974

    @manikandankm3974

    4 жыл бұрын

    @@LearnAutomationOnline 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

  • @AmarNath-qf1nr
    @AmarNath-qf1nr Жыл бұрын

    Is it required to learn the formats of XML file and Properties file or copy pasting from Google would suffice ? I understood the explanation but those formats are a bit difficult to grasp.

  • @LearnAutomationOnline

    @LearnAutomationOnline

    Жыл бұрын

    If u understand the contents of the file, it is enough. It's not easy to remember it the first time, but when u do it regularly, u will grasp it

  • @AmarNath-qf1nr

    @AmarNath-qf1nr

    Жыл бұрын

    Ok brother... thank you

  • @elakyad1384
    @elakyad13842 жыл бұрын

    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?

  • @LearnAutomationOnline

    @LearnAutomationOnline

    2 жыл бұрын

    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 .

  • @Mohan-sj4fz
    @Mohan-sj4fz Жыл бұрын

    Hi Sir! i am happy to say that i have learned many concepts with your support and can you please come up with new video of Logger4java, because there no option in buildpath to refer jar folder in classpath level and more log4j jar while extract from web and cant import the above statement in my eclipse

  • @LearnAutomationOnline

    @LearnAutomationOnline

    Жыл бұрын

    When adding the jar, click on classpath under libraries, u will see the add external jar button enabled.

  • @Mohan-sj4fz

    @Mohan-sj4fz

    Жыл бұрын

    @@LearnAutomationOnline Hi sir there is no classpath under libraries(this is problem i am facing), i could see in your video and not in my eclipse & in addition to that i am happy to share i have learned selinium, test NG and Maven and java concepts and many more. all this as become possible just because of your videos.Thank you

  • @LearnAutomationOnline

    @LearnAutomationOnline

    Жыл бұрын

    @@Mohan-sj4fz if u learnt maven, why struggling with adding jars manually, simply add the maven dependency for log4j.

  • @Mohan-sj4fz

    @Mohan-sj4fz

    Жыл бұрын

    @@LearnAutomationOnline i have successfully added log4j dependencies in new maven project which has two jar and your logger4j video you have added only one jar which is in java project and in my system came to know not able to refer those jar in classpath(option not available in library section) which is simple java project, not maven project.Sir!! Now i will be able to practice with maven project. Thank you so much!!!

  • @Mohan-sj4fz

    @Mohan-sj4fz

    Жыл бұрын

    @@LearnAutomationOnline Sir! i cannot create object for logger class. import statement is also sugesting me to create class 'logger' in package 'org.apache.log4j'

  • @PriyaDharshini-bf1hq
    @PriyaDharshini-bf1hq2 жыл бұрын

    is there any pre requitse regarding log4j? ipodhan first time ipdi oru video pakren enaku romba different a eruku

  • @LearnAutomationOnline

    @LearnAutomationOnline

    2 жыл бұрын

    This is the only video for log4j you will need. I have explained almost everything with respect to log4j. No prerequisites to this

  • @PriyaDharshini-bf1hq

    @PriyaDharshini-bf1hq

    2 жыл бұрын

    @@LearnAutomationOnline ok bro

  • @suriyakb4299
    @suriyakb4299 Жыл бұрын

    Bro en nama intha logger ah static podurom

  • @LearnAutomationOnline

    @LearnAutomationOnline

    Жыл бұрын

    We need only one logger

  • @udhayasankara5442
    @udhayasankara5442Ай бұрын

    hi arul i got FileNotFoundException

  • @LifeLessionsAcademy
    @LifeLessionsAcademy2 жыл бұрын

    now logger is available in java also.. is both the same or different.

  • @LearnAutomationOnline

    @LearnAutomationOnline

    2 жыл бұрын

    Different

  • @saravanakumarramasamy8603
    @saravanakumarramasamy8603 Жыл бұрын

    hi bro kindly increase the video quality..

  • @alwinj4229
    @alwinj42292 жыл бұрын

    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

  • @LearnAutomationOnline

    @LearnAutomationOnline

    2 жыл бұрын

    U will use logger only in production ready framework. When u r just learning. U can use sysout

  • @alwinj4229

    @alwinj4229

    2 жыл бұрын

    @@LearnAutomationOnline 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 ......

  • @LearnAutomationOnline

    @LearnAutomationOnline

    2 жыл бұрын

    Yes, for errors u will use error, for general message, u will use logger info , warning and so on.

  • @alwinj4229

    @alwinj4229

    2 жыл бұрын

    Nice bro romba romba nandri Thanks a lot...... 💝

  • @sundharyuvi8221
    @sundharyuvi82214 жыл бұрын

    How to give a executable jar

  • @LearnAutomationOnline

    @LearnAutomationOnline

    4 жыл бұрын

    You can use export option in eclipse to generate executable jar. Please refer to maven series I have explained in detail about these processes.

  • @sundharyuvi8221

    @sundharyuvi8221

    4 жыл бұрын

    @@LearnAutomationOnline thanks bro

  • @Fatyboy
    @Fatyboy Жыл бұрын

    Sir... Sudden a ....namba code theriyama mistake panni.. Ethachii error or exception vanthu ... Log4j pa enna varum.... Because athukaparam Iruka testcase um run agathu so ... Athu epdi sir... Pleased explain me

  • @LearnAutomationOnline

    @LearnAutomationOnline

    Жыл бұрын

    Previous ah log statements la ethu varaikum iruko athukapram execute agala nu identify panika vendithan

  • @Fatyboy

    @Fatyboy

    Жыл бұрын

    @@LearnAutomationOnline oh... Okay sir... Illa athukum vera ethachii techniques irukumoo ... Nenachita. Sir ...

  • @sriluxman
    @sriluxman2 жыл бұрын

    Log4J: Summa therika vidalaaama... Cyber security: Macha.. Sachiputa macha! 😳 Minecraft: Game over

  • @LearnAutomationOnline

    @LearnAutomationOnline

    2 жыл бұрын

    😅

  • @abuthahir9342

    @abuthahir9342

    2 жыл бұрын

    Wat realy hpnd?

  • @mahendrarajv3892
    @mahendrarajv3892 Жыл бұрын

    Sir %x means you will not said sir

  • @LifeLessionsAcademy
    @LifeLessionsAcademy2 жыл бұрын

    pls upload new version if possible

  • @LearnAutomationOnline

    @LearnAutomationOnline

    2 жыл бұрын

    There’s no big difference. In cucumber framework playlist I have explained log4j2. Please refer them

  • @LifeLessionsAcademy

    @LifeLessionsAcademy

    2 жыл бұрын

    @@LearnAutomationOnlinesure... thank you...

  • @user-oj3dd8ci9d
    @user-oj3dd8ci9d4 жыл бұрын

    Why java consept

  • @LearnAutomationOnline

    @LearnAutomationOnline

    4 жыл бұрын

    Purila!! Ena keka varinga

  • @user-oj3dd8ci9d

    @user-oj3dd8ci9d

    4 жыл бұрын

    Bro number send me

  • @LearnAutomationOnline

    @LearnAutomationOnline

    4 жыл бұрын

    Sorry bro. I'm not comfortable in sharing my number. You can ask your doubts, in comments or on Instagram

  • @user-oj3dd8ci9d

    @user-oj3dd8ci9d

    4 жыл бұрын

    I am 10 th patichuruken java kojam therium ana piriya matinkuthu itha concept la atha

  • @LearnAutomationOnline

    @LearnAutomationOnline

    4 жыл бұрын

    Neenga straight ah intha videos pakringla, illa selenium videos lam pathutu pakringla. Ungaluku java venumna neenga straight ah java videos paklam. Ithellam java use pani daily life la, oru software professional ku ena thevayo atha explain panirupen

  • @vijiviji-jq4wr
    @vijiviji-jq4wr5 жыл бұрын

    What is the configuration to write in Database

  • @LearnAutomationOnline

    @LearnAutomationOnline

    5 жыл бұрын

    I dont understand your question. You are asking how to write the logs to database? I presume!

  • @vijiviji-jq4wr

    @vijiviji-jq4wr

    5 жыл бұрын

    @@LearnAutomationOnline yes..

  • @LearnAutomationOnline

    @LearnAutomationOnline

    5 жыл бұрын

    No that's not advisable. Data base operations are costly. We should not write logs into database.

  • @vijiviji-jq4wr

    @vijiviji-jq4wr

    5 жыл бұрын

    @@LearnAutomationOnline OK Arul.. Tq..

  • @surendransms6350
    @surendransms63506 ай бұрын

    Bro onnume puriyala bro

  • @rajmohammed6229
    @rajmohammed6229 Жыл бұрын

    Hi Arul, getting this error Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger at log4jExamples.BasicConfiguratorExample.(BasicConfiguratorExample.java:8) Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 1 more

  • @pavithras2304
    @pavithras2304 Жыл бұрын

    Bro i get this error. Please reply log4j:ERROR Could not instantiate class [org.apache.log4.PatternLayout]. java.lang.ClassNotFoundException: org.apache.log4.PatternLayout at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:375) at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198) at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:327) at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:124) at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:797) at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768) at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:395) at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:403) at log4jExample.PropertyConfiguratorlog4jExample.main(PropertyConfiguratorlog4jExample.java:11) [PropertyConfiguratorlog4jExample] [ERROR] error msg [PropertyConfiguratorlog4jExample] [WARN] warning msg [PropertyConfiguratorlog4jExample] [FATAL] fatal msg PropertyConfiguratorlog4jExample: package log4jExample; import org.apache.log4j.PropertyConfigurator; import org.testng.log4testng.Logger; public class PropertyConfiguratorlog4jExample { static Logger logger = Logger.getLogger(PropertyConfiguratorlog4jExample.class); public static void main(String[] args) { PropertyConfigurator.configure("log4j.properties"); logger.debug("debug msg"); logger.info("info msg"); logger.warn("warning msg"); logger.error("error msg"); logger.fatal("fatal msg"); } } log4j.properties: #Root logger log4j.rootLogger = INFO, file #configuration to print into file #Appender log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.File=C:\\Users\\Pavithra\\Downloads\\log\\logging.log log4j.appender.file.MaxFileSize=12MB log4j.appender.file.MaxBackupIndex=10 #Layout log4j.appender.file.layout=org.apache.log4.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n Created a folder name - log. Like you said deleted the logging file

Келесі