filmov
tv
Selenium Framework for Beginners 14 | What is Log4j | How to add Log4j in java project
Показать описание
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
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
Комментарии