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.AbstractStringLayoutLayout for log4j to emit JSON format, including exceptions. In addition, it will also append all values added to the current thread withContextclass.- 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
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJsonLog4j2Layout()protectedJsonLog4j2Layout(Charset charset, String dateFormat)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JsonLog4j2LayoutcreateLayout(Charset charset, String dateFormat)StringtoSerializable(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
-
-
-
-
Method Detail
-
toSerializable
public String toSerializable(org.apache.logging.log4j.core.LogEvent event)
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)
-
-