donaricano-btn

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


'Logging > Log4j' 카테고리의 다른 글

[Log4j] How to use  (0) 2016.05.23
[Log4j] Install and Architecture  (0) 2016.05.20
[Log4j] Define  (0) 2016.05.20
블로그 이미지

리딩리드

,