Package org.javalite.logging
Class JsonLog4j2Layout
java.lang.Object
org.apache.logging.log4j.core.layout.AbstractLayout<String>
org.apache.logging.log4j.core.layout.AbstractStringLayout
org.javalite.logging.JsonLog4j2Layout
- All Implemented Interfaces:
org.apache.logging.log4j.core.impl.LocationAware
,org.apache.logging.log4j.core.Layout<String>
,org.apache.logging.log4j.core.layout.Encoder<org.apache.logging.log4j.core.LogEvent>
,org.apache.logging.log4j.core.StringLayout
@Plugin(name="JsonLog4j2Layout",
category="Core",
elementType="layout",
printObject=true)
public class JsonLog4j2Layout
extends org.apache.logging.log4j.core.layout.AbstractStringLayout
Layout for log4j to emit JSON format, including exceptions. In addition, it will also append all
values added to the current thread with
Context
class.- Author:
- igor on 1/12/17.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout
org.apache.logging.log4j.core.layout.AbstractStringLayout.Builder<B extends org.apache.logging.log4j.core.layout.AbstractStringLayout.Builder<B>>, org.apache.logging.log4j.core.layout.AbstractStringLayout.Serializer, org.apache.logging.log4j.core.layout.AbstractStringLayout.Serializer2
-
Field Summary
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, header, LOGGER
Fields inherited from interface org.apache.logging.log4j.core.Layout
ELEMENT_TYPE
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
JsonLog4j2Layout(Charset charset, String dateFormat)
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonLog4j2Layout
createLayout(Charset charset, String dateFormat)
toSerializable(org.apache.logging.log4j.core.LogEvent event)
Formats aLogEvent
.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, getContentFormat, markEvent
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.logging.log4j.core.layout.Encoder
encode
Methods inherited from interface org.apache.logging.log4j.core.Layout
getContentFormat
-
Constructor Details
-
JsonLog4j2Layout
protected JsonLog4j2Layout() -
JsonLog4j2Layout
-
-
Method Details
-
toSerializable
Formats aLogEvent
.- Parameters:
event
- The LogEvent.- Returns:
- The XML representation of the LogEvent.
-
createLayout
@PluginFactory public static JsonLog4j2Layout createLayout(@PluginAttribute(value="charset",defaultString="UTF-8") Charset charset, @PluginAttribute(value="dateFormat",defaultString="yyyy-MM-dd HH:mm:ss.SSS") String dateFormat)
-