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
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
3 жыл бұрын
Glad it was helpful!
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.
Great Video and happy to know that the best content on testing is available in tamil. Keep Posting
dheivamae u r great plz continue to do such videos we will support u
Excellent teaching Making new to software like me to understand concepts
Excellent Explaination Arul! Thanks a lot !
Very nice explanation 😁 I was waiting for a session like this.. Keep rocking.. 😎
@LearnAutomationOnline
5 жыл бұрын
Thanks a lot. Keep learning. 😊
Hi Arul, good detailed info on log4j, Thank you !
Clean Explanation Arul Bro 👏👏
Neenga yepdi debug pannuvinga In eclipse if facing issue in script Do u use log file instead of debugging
excellent information..thanku so much
Thankyou for this knowledge
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?
Excellent explanation...
Good work, clear explanation
Hi Arul, This video is very useful for me, and i executed successfully my script also
@LearnAutomationOnline
3 жыл бұрын
Great 👍
Thank you
Excellent sir
Thank you for the tutorial
You're the best sir..
Thank you so much for this great explanation
@LearnAutomationOnline
3 жыл бұрын
😊
Thank you.
great explanation bro
Thanks😊, You are underrated😢
Sir in this video for Basic configurator.. %x denotes?
Hi Arul, very nice explanation, What does mean slf4j ?
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
5 жыл бұрын
Almost. Different name for different implementation. Function same
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
2 жыл бұрын
yes bro for me to same error
Some key didn't display what will I do sir
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
4 жыл бұрын
Are you getting the output or u r getting the exception and the program is not proceeding further?
@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
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
Жыл бұрын
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
Жыл бұрын
Ok brother... thank you
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
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 .
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
Жыл бұрын
When adding the jar, click on classpath under libraries, u will see the add external jar button enabled.
@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
Жыл бұрын
@@Mohan-sj4fz if u learnt maven, why struggling with adding jars manually, simply add the maven dependency for log4j.
@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
Жыл бұрын
@@LearnAutomationOnline Sir! i cannot create object for logger class. import statement is also sugesting me to create class 'logger' in package 'org.apache.log4j'
is there any pre requitse regarding log4j? ipodhan first time ipdi oru video pakren enaku romba different a eruku
@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
2 жыл бұрын
@@LearnAutomationOnline ok bro
Bro en nama intha logger ah static podurom
@LearnAutomationOnline
Жыл бұрын
We need only one logger
hi arul i got FileNotFoundException
now logger is available in java also.. is both the same or different.
@LearnAutomationOnline
2 жыл бұрын
Different
hi bro kindly increase the video quality..
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
2 жыл бұрын
U will use logger only in production ready framework. When u r just learning. U can use sysout
@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
2 жыл бұрын
Yes, for errors u will use error, for general message, u will use logger info , warning and so on.
@alwinj4229
2 жыл бұрын
Nice bro romba romba nandri Thanks a lot...... 💝
How to give a executable jar
@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
4 жыл бұрын
@@LearnAutomationOnline thanks bro
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
Жыл бұрын
Previous ah log statements la ethu varaikum iruko athukapram execute agala nu identify panika vendithan
@Fatyboy
Жыл бұрын
@@LearnAutomationOnline oh... Okay sir... Illa athukum vera ethachii techniques irukumoo ... Nenachita. Sir ...
Log4J: Summa therika vidalaaama... Cyber security: Macha.. Sachiputa macha! 😳 Minecraft: Game over
@LearnAutomationOnline
2 жыл бұрын
😅
@abuthahir9342
2 жыл бұрын
Wat realy hpnd?
Sir %x means you will not said sir
pls upload new version if possible
@LearnAutomationOnline
2 жыл бұрын
There’s no big difference. In cucumber framework playlist I have explained log4j2. Please refer them
@LifeLessionsAcademy
2 жыл бұрын
@@LearnAutomationOnlinesure... thank you...
Why java consept
@LearnAutomationOnline
4 жыл бұрын
Purila!! Ena keka varinga
@user-oj3dd8ci9d
4 жыл бұрын
Bro number send me
@LearnAutomationOnline
4 жыл бұрын
Sorry bro. I'm not comfortable in sharing my number. You can ask your doubts, in comments or on Instagram
@user-oj3dd8ci9d
4 жыл бұрын
I am 10 th patichuruken java kojam therium ana piriya matinkuthu itha concept la atha
@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
What is the configuration to write in Database
@LearnAutomationOnline
5 жыл бұрын
I dont understand your question. You are asking how to write the logs to database? I presume!
@vijiviji-jq4wr
5 жыл бұрын
@@LearnAutomationOnline yes..
@LearnAutomationOnline
5 жыл бұрын
No that's not advisable. Data base operations are costly. We should not write logs into database.
@vijiviji-jq4wr
5 жыл бұрын
@@LearnAutomationOnline OK Arul.. Tq..
Bro onnume puriyala bro
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
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