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>
additionalProperties
protected ExceptionFormatter
exceptionFormatter
protected MdcFilter
mdcFilter
protected MessageFormatter
messageFormatter
-
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 String
apply(LogEvent e)
void
configure(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)
String
toString()
protected void
writeJsonObject(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:
configure
in 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)
-
-