Thursday 17, Apr 2025
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

Related Posts:

  • Log4j – RollingFileAppender using XML configurationIn this tutorials we are going to see how to create simple log4j application with RollingFileAppender using XML configuration RollingFileAppederRollingFileAppender is used to create log message in multiple files,RollingFileAp… Read More
  • Log4j – RollingFileAppender using Property ConfigurationIn this tutorials we are going to see how to create simple log4j application with RollingFileAppender using property configuration RollingFileAppederRollingFileAppender is used to create log message in multiple files,Rolling… Read More
  • Log4j – logging in File using Property ConfigurationIn this tutorials we are going to see how to create simple log4j application to logging message into file using Property Configurator with java program.org.apache.log4j.FileAppender used to log the message in file, configurat… Read More
  • Log4j Example using xml configurationIn this tutorials we are going to see how to create simple log4j application using XML file Configuration with java program, previously we have seen log4j application using log4j using Property Configurator we can obtain same… Read More
  • 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 abstrac… Read More
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

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