How to use the log4j
1. properties
1_1 properties
1_2. java
2. XML
'Logging > Log4j' 카테고리의 다른 글
[Log4j] Configuration (0) | 2016.05.20 |
---|---|
[Log4j] Install and Architecture (0) | 2016.05.20 |
[Log4j] Define (0) | 2016.05.20 |
How to use the log4j
1. properties
1_1 properties
1_2. java
2. XML
[Log4j] Configuration (0) | 2016.05.20 |
---|---|
[Log4j] Install and Architecture (0) | 2016.05.20 |
[Log4j] Define (0) | 2016.05.20 |
Configuration
It explains how you can configure the core components using a configuration file
Configuring log4j involves assigning the Level, defining Appender, and specifying Layout objects in a configuration file
1. log4j.properties
By default, the LogManager looks for a file named log4j.properties in the CLASSPATH
- The level of the root logger is defined as DEBUG. The DEBUG attaches the appender named X to it
- set the appender named X to be a valid appender
- Set the layout for the appender x
2. Debug Level
TRACE < DEBUG < INFO < WARN < ERROR < FATAL < ALL
3. Appenders
Apache log4j provides Appender objects which are primarily responsible for printing logging messages to different destinations
Each Appender object has different properties associated with it
3_1. properties set
log4j.logger.[logger-name]=level, appender1, appender..n
ex) log4j.appender.console = org.apache.log4j.ConsoleAppender
3_2. XML
3_3. Appender
- ConsoleAppender : output log data on the console
- FileAppender : log message is written on the file
- RollingFileAppender : The log message is written to a file and If File size is full, It makes a new file
- DailyRollingFileAppender : log message is written to a file and It makes a new file each day
- SMTPAppender : Send log message by using email
4. Layout
DateLayout : Record the log data by its creation time
HTMLLayout : Record the log data of HTML form
[Log4j] How to use (0) | 2016.05.23 |
---|---|
[Log4j] Install and Architecture (0) | 2016.05.20 |
[Log4j] Define (0) | 2016.05.20 |
Install and Architecture
1. Install
- http://logging.apache.org/log4j/1.2/download.html
- To unzip the file and add a lib to java
2. Architecture
2_1. Core objects
- These are mandatory objects of the framework. They are required to use the framework
2_2. Support objects
- These are optional objects of the framework. They support core objects to perform additional but important tasks
3. Core Objects
3_1 . Logger Object
- The top-level layer is the Logger which provide the Logger object.
- The Logger object is responsible for capturing logging information and they are stored in a namespace hierarchy
3_2. Layout Object
- The layout layer provides objects which are used to format logging information in different styles
- It provides support to appender objects before publishing logging information
3_3. Appender Object
- This is a lower-level layer which provides Appender objects. The Appender object is responsible for publishing logging information to various preferred destinations such as a database, file, consol..
[Log4j] How to use (0) | 2016.05.23 |
---|---|
[Log4j] Configuration (0) | 2016.05.20 |
[Log4j] Define (0) | 2016.05.20 |
Define
log4j is a reliable, fast and flexible logging framework written in Java, which is distributed under the Apache Software License
log4j has been ported to the C, C++, C# Perl, Python, Ruby...
1. Main components
- loggers : Responsible for capturing logging information
- appenders : Responsible for publishing logging information to various preferred destinations
- layouts : Responsible for formatting logging information in different styles
[Log4j] How to use (0) | 2016.05.23 |
---|---|
[Log4j] Configuration (0) | 2016.05.20 |
[Log4j] Install and Architecture (0) | 2016.05.20 |