Selenium Framework for Beginners 14 | What is Log4j | How to add Log4j in java project

preview_player
Показать описание
Today we will learn What is Log4j and How to use it
1 What is Log4j
2 How to implement Log4j in Java Project

helpful tips

What is Log4j

Log4j is a java based logging framework
Is simple, flexible, reliable and fast
Is configured through a configuration file

Practical Example

Step 1:Add Log4j libraries in the java project
Can add jar files or maven dependency

Step 2 : Create reference for Logger in the class
Class where you want to add log statements

What is the difference ?

Step 4 : Run and Validate

Log4j - log levels

TRACE
Most detailed information. Expect these to be written to logs only. Since version 1.2.12

DEBUG
Detailed information on the flow through the system. Expect these to be written to logs only. Generally speaking, most lines logged by your application should be written as DEBUG

INFO
Interesting runtime events (startup/shutdown). Expect these to be immediately visible on a console, so be conservative and keep to a minimum.

WARN
Use of deprecated APIs, poor use of API, 'almost' errors, other runtime situations that are undesirable or unexpected, but not necessarily "wrong". Expect these to be immediately visible on a status console.

ERROR
Other runtime errors or unexpected conditions. Expect these to be immediately visible on a status console.

FATAL
Severe errors that cause premature termination. Expect these to be immediately visible on a status console.

OFF
The highest possible rank and is intended to turn off logging.

** built-in log levels with increasing order of severity

helpful tips

You can configure to append or overwrite logs in file

You can set logging OFF when not required
in case heavy logging is making your runs slower...

Log4j - Configuration File

Log4j is configured through a configuration file

Configuration files can be written in XML, JSON, YAML, or properties file format

Set of key-value pairs

Within a configuration you can define three main components:
Loggers
Appenders
Layouts

Configuring logging via a file has the advantage that logging can be turned on or off without modifying the application that uses Log4j.

Log4j - FAQ

Written in Java | Cross platform

part of the Apache Logging Services

initial release - January 8, 2001

On August 5, 2015 the Apache Logging Services Project Management Committee announced that Log4j 1 had reached end of life and that users of Log4j 1 are recommended to upgrade to Apache Log4j 2.

REFERENCES

PLAYLISTS

KATALON STUDIO

SELENIUM BEGINNERS

SELENIUM JAVA FRAMEWORK BEGINNERS

SELENIUM TIPS

SELENIUM PYTHON

JAVA

JENKINS

JMETER BEGINNER

JMETER TIPS & TRICKS

SOAPUI

POSTMAN

GIT & GITHUB

DOCKER

ROBOT FRAMEWORK

WEB SERVICES (API)

MAVEN

TOOLS & TIPS

QnA FRIDAY

ALL PLAYLISTS

Like on FACEBOOK :

Follow on TWITTER:

Subscribe on YOUTUBE :

________ ONLINE COURSES TO LEARN ________

Never Stop Learning
Raghav
Рекомендации по теме
Комментарии
Автор

seriously sir your tutorial got me out from 24 hrs wasted on checking from every where but your simple method solve my trouble of log 4j2 just 20 minutes thank you so much

onkardhavale
Автор

Am tied up watching all log4j videos and didn't any solution for making log 4j in maven project. But from this video I was successfully created logs without any errors. Thank you so much for making this video sir....

nadiyagone
Автор

Best tutorial for log4j on internet. Explained with great details...no doubts...

NPRBEST
Автор

just perfect ! clean and tidy explanation !thank you very much!

Nstyleonlineuk
Автор

You never disappoint.
Thanks and keep posting more.
Try covering end to end development videos

virendrasinghbais
Автор

This is exactly what I was looking for. This playlist is very helpful, helped me to PRACTICE before going out for interview. But in my opinion, this is not a beginner

Mostafizur_rahman
Автор

thank you! this is exactly the video I was looking for

brucemyklebust
Автор

THE BEST VIDEO I HAVE SEEN ON THE SUBJECT!!
Thank you very much, it has helped me a lot.
The entire playlist is a gem.

jaquelinecuatepitzibastida
Автор

Very good bro
Do more and more and boostup us

sridharmamidipaka
Автор

Thank you so much ..we learn alot of thing about automation .. really appreciate sir ...

shehlaabdullah
Автор

As usual ver y well explained and never disappointed, I have been following your tutorials for my new job trials.

ashwinireddy
Автор

Hi raghav, You have explained in very neat manner, especially at the end of the video. Thanks, this will be very useful for me in company.

kamaljitxSingh
Автор

Hi Raghav,
First thanks for all efforts for us.
I am facing a issue. As following this clip Log file is getting generate in logs folder but logs are not getting append inside the file. It show blank, where as logs are showing on console. Please guide on this. Thanks.

ahsan
Автор

Very neat and clear explanation thanks for your help..

deviyadlapalli
Автор

It's a very detailed explanations thank you.

lucylucy
Автор

Hi Raghav, thanks a lot !!
The information you provided will enough to rock the technology..
Thanks once again 😃..

rhacker
Автор

Beautifully clear. Thank you so much!

brandonflorida
Автор

13:46 Very important part. If you don't put package name after "logger.file.name=", your log file will come out empty!

sumam
Автор

Thank you so so much for this video ... it works flawlessly

dineshkmr
Автор

I will say just amazing explanation....

EliasHossein