We are moved to new domain
Click -> www.ehowtonow.com
Tuesday, 3 September 2013

Log4j – PatternLayout


Log4j PatternLayout is used to customize your log message format.The class org.apache.log4j.PatternLayout is used for set your layout pattern.The Pattern layout class extends the org.apache.log4j.Layout,which is abstract class.PatternLayout provide the following property to set layout.

Property

Description

conversionPattern This property used to set conversion pattern.

Conversion Pattern Configurations

Configuration available in conversion pattern given below.

Conversion Character

Description

c Used to print the category of log even.Example,The category name com.javatutorialscorner.log4j.jdbcappender the pattern %c{3} print com.javatutorialscorner.log4j
C Used to print the fully qualified class name where the log method called.Example %C will print  com.javatutorialscorner.log4j.jdbcappender.JDBCAppender  and %C{1} will print JDBCAppender alone.
d used to set the date of even.You can use any supported date pattern
F Used to print the file name of log event called
l used to print the location information of log even called
L used to print the line number of log event called
m Used to print the log message
M Used to print the method name of log event called
n platform depended line separator
p used to print the priority of log event
r Used to print the number of millisecond elapsed from formation of layout until the creation of log event
t Used to print the name of thread
x Used to print the NDC
X Used with MDC.example X{user}.This will print the MDC value stored for key user
% Used to print the log

Note:I used pattern layout almost all log4j example

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: Log4j – PatternLayout Rating: 5 Reviewed By: eHowToNow