Package org.logevents.formatters
Class JsonLogEventFormatter
- java.lang.Object
-
- org.logevents.formatters.JsonLogEventFormatter
-
- All Implemented Interfaces:
Function<LogEvent,String>,LogEventFormatter
- Direct Known Subclasses:
ConsoleJsonLogEventFormatter
public class JsonLogEventFormatter extends Object implements LogEventFormatter
Used to format a LogEvent as JSON for stdout or network observers. Example configuration:observer.foo.formatter=JsonLogEventFormatter observer.foo.formatter.excludedMdcKeys=secret,ipAddress observer.foo.formatter.properties.environment=staging
- Author:
- Johannes Brodwall
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,String>additionalPropertiesprotected ExceptionFormatterexceptionFormatterprotected MdcFiltermdcFilterprotected MessageFormattermessageFormatter
-
Constructor Summary
Constructors Constructor Description JsonLogEventFormatter()JsonLogEventFormatter(Map<String,String> properties, String prefix)JsonLogEventFormatter(Configuration configuration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringapply(LogEvent e)voidconfigure(Configuration configuration)reads applicationName, nodeName, messageFormatter, mdcFilter, dateTimeFormat and propertiesstatic Map<String,Object>toJsonObject(Throwable throwable, ExceptionFormatter exceptionFormatter)protected Map<String,String>toJsonObject(List<org.slf4j.event.KeyValuePair> keyValuePairs)Map<String,Object>toJsonObject(LogEvent event)StringtoString()protected voidwriteJsonObject(LogEvent event, Map<String,Object> payload)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.logevents.LogEventFormatter
getExceptionFormatter
-
-
-
-
Field Detail
-
messageFormatter
protected MessageFormatter messageFormatter
-
exceptionFormatter
protected ExceptionFormatter exceptionFormatter
-
mdcFilter
protected MdcFilter mdcFilter
-
-
Constructor Detail
-
JsonLogEventFormatter
public JsonLogEventFormatter()
-
JsonLogEventFormatter
public JsonLogEventFormatter(Configuration configuration)
-
-
Method Detail
-
configure
public void configure(Configuration configuration)
reads applicationName, nodeName, messageFormatter, mdcFilter, dateTimeFormat and properties- Specified by:
configurein interfaceLogEventFormatter
-
toJsonObject
protected final Map<String,String> toJsonObject(List<org.slf4j.event.KeyValuePair> keyValuePairs)
-
toJsonObject
public static Map<String,Object> toJsonObject(Throwable throwable, ExceptionFormatter exceptionFormatter)
-
-