Log4j Format Specification: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 9: Line 9:
=Overview=
=Overview=


log4j calls its output format ''layout''. Most commonly used is the [[#Pattern_Layout|pattern layout]].
log4j calls its output format ''layout''. Most commonly used is the [[Log4j_Pattern_Layout#Overview|pattern layout]].


=Pattern Layout=
=Pattern Layout=


{{External|http://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout}}
{{Internal|Log4j Pattern Layout|Log4j Pattern Layout}}
 
The pattern layout is defined by a [[#Conversion_Pattern|conversion pattern]] string.
 
==Conversion Pattern==
 
A conversion pattern string , where various elements of a log event can be referred and the way they are intended to be displayed in a log file specified. The conversion pattern is closely related to the conversion pattern of the [[printf]] function in C. The conversion pattern is composed of:
* [[#Literal_Text|literal text]]
* [[#Conversion_Specifier|conversion specifiers]]
 
===Literal Text===
 
Literal text may include special characters (\t, \n \r \f). '\\' can be used to insert a backslash in the output.
 
===Conversion Specifier===
 
Each ''conversion specifier'' starts with a percent sign ('%') and it is followed by an optional [[#Format_Modifier|format modifier]] and a mandatory ''[[#Conversion_Character|conversion character]]'':
 
%-5c
 
====Format Modifier====
 
A ''format modifier'' modifies how the data generated by the [[#Conversion_Specifier|conversion specifier]] is displayed: field with, padding and justification.
 
====Conversion Character====
 
The ''conversion character'' specifies the type of data:
 
* category
* priority
* date
* thread name

Latest revision as of 19:59, 15 November 2017

External

Internal

Overview

log4j calls its output format layout. Most commonly used is the pattern layout.

Pattern Layout

Log4j Pattern Layout