filmov
tv
TestNG Class 24: How to add Log4j properties file in Java project
Показать описание
How to add Log4j properties file in Java project
1 What is Log4j
2 How to implement Log4j in Java Project
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
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
#name=PropertiesConfig
appenders = console, file
loggers=file
1 What is Log4j
2 How to implement Log4j in Java Project
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
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
#name=PropertiesConfig
appenders = console, file
loggers=file
Комментарии