Log4j Format Specification: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 15: Line 15:
{{External|http://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout}}
{{External|http://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout}}


The pattern layout is defined by a [[#Conversion_Pattern|conversion pattern]] string, where various element 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:
The pattern layout is defined by a [[#Conversion_Pattern|conversion pattern]] string.
 
==Conversion Pattern==
 
A conversion pattern string , where various element 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]]
* [[#Literal_Text|literal text]]
* [[#Conversion_Specifier|conversion specifiers]]
* [[#Conversion_Specifier|conversion specifiers]]
==Conversion Pattern==


===Literal Text===
===Literal Text===

Revision as of 18:00, 15 November 2017

External

Internal

Overview

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

Pattern Layout

http://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout

The pattern layout is defined by a conversion pattern string.

Conversion Pattern

A conversion pattern string , where various element 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 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 and a mandatory conversion character.

Format Modifier

A format modifier modifies how the data generated by the pattern layout element

Conversion Character

The conversion character specifies the type of data (category, priority, date, thread name, etc)