Package org.apache.log4j.layout
Class Log4j1SyslogLayout
java.lang.Object
org.apache.logging.log4j.core.layout.AbstractLayout<String>
org.apache.logging.log4j.core.layout.AbstractStringLayout
org.apache.log4j.layout.Log4j1SyslogLayout
- All Implemented Interfaces:
LocationAware
,Layout<String>
,Encoder<LogEvent>
,StringLayout
@Plugin(name="Log4j1SyslogLayout",
category="Core",
elementType="layout",
printObject=true)
public final class Log4j1SyslogLayout
extends AbstractStringLayout
Port of the layout used by SyslogAppender in Log4j 1.x. Provided for
compatibility with existing Log4j 1 configurations.
Originally developed by Ceki Gülcü and Anders Kristensen.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builds a SyslogLayout.Nested classes/interfaces inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout
AbstractStringLayout.Serializer, AbstractStringLayout.Serializer2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LogEventPatternConverter
private static final String[]
Date format used if header = true.private final Facility
private final boolean
private final boolean
private static final String
Host name used to identify messages from this appender.private final StringLayout
Fields inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout
DEFAULT_STRING_BUILDER_SIZE, MAX_STRING_BUILDER_SIZE
Fields inherited from class org.apache.logging.log4j.core.layout.AbstractLayout
configuration, eventCount, footer, LOGGER
Fields inherited from interface org.apache.logging.log4j.core.Layout
ELEMENT_TYPE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Log4j1SyslogLayout
(Facility facility, boolean facilityPrinting, boolean header, StringLayout messageLayout, Charset charset) -
Method Summary
Modifier and TypeMethodDescriptionGets this SyslogLayout's content format.static <B extends Log4j1SyslogLayout.Builder<B>>
BtoSerializable
(LogEvent event) Formats aLogEvent
in conformance with the BSD Log record format.Methods inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout
getBytes, getCharset, getContentType, getFooter, getFooterSerializer, getHeader, getHeaderSerializer, getStringBuilder, getStringBuilderEncoder, requiresLocation, serializeToBytes, serializeToString, toByteArray, trimToMaxSize
Methods inherited from class org.apache.logging.log4j.core.layout.AbstractLayout
encode, getConfiguration, markEvent
-
Field Details
-
localHostname
Host name used to identify messages from this appender. -
facility
-
facilityPrinting
private final boolean facilityPrinting -
header
private final boolean header -
messageLayout
-
dateFormatOptions
Date format used if header = true. -
dateConverter
-
-
Constructor Details
-
Log4j1SyslogLayout
private Log4j1SyslogLayout(Facility facility, boolean facilityPrinting, boolean header, StringLayout messageLayout, Charset charset)
-
-
Method Details
-
newBuilder
-
toSerializable
Formats aLogEvent
in conformance with the BSD Log record format.- Parameters:
event
- The LogEvent- Returns:
- the event formatted as a String.
-
getContentFormat
Gets this SyslogLayout's content format. Specified by:- Key: "structured" Value: "false"
- Key: "dateFormat" Value: "MMM dd HH:mm:ss"
- Key: "format" Value: "<LEVEL>TIMESTAMP PROP(HOSTNAME) MESSAGE"
- Key: "formatType" Value: "logfilepatternreceiver" (format uses the keywords supported by LogFilePatternReceiver)
- Specified by:
getContentFormat
in interfaceLayout<String>
- Overrides:
getContentFormat
in classAbstractLayout<String>
- Returns:
- Map of content format keys supporting SyslogLayout
-