Class MessageJsonProvider
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
net.logstash.logback.composite.AbstractJsonProvider<Event>
net.logstash.logback.composite.AbstractFieldJsonProvider<ILoggingEvent>
net.logstash.logback.composite.loggingevent.MessageJsonProvider
- All Implemented Interfaces:
ContextAware
,FieldNamesAware<LogstashFieldNames>
,JsonProvider<ILoggingEvent>
public class MessageJsonProvider
extends AbstractFieldJsonProvider<ILoggingEvent>
implements FieldNamesAware<LogstashFieldNames>
-
Field Summary
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionWrite the message as a JSON array by splitting the message text using the specified regex.void
setFieldNames
(LogstashFieldNames fieldNames) void
setMessageSplitRegex
(String messageSplitRegex) Write the message as a JSON array by splitting the message text using the specified regex.void
writeTo
(JsonGenerator generator, ILoggingEvent event) Writes information about the event, to the given generator.Methods inherited from class net.logstash.logback.composite.AbstractFieldJsonProvider
getFieldName, setFieldName
Methods inherited from class net.logstash.logback.composite.AbstractJsonProvider
assertIsStarted, isStarted, prepareForDeferredProcessing, start, stop
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Field Details
-
FIELD_MESSAGE
- See Also:
-
-
Constructor Details
-
MessageJsonProvider
public MessageJsonProvider()
-
-
Method Details
-
writeTo
Description copied from interface:JsonProvider
Writes information about the event, to the given generator.When called, the generator is assumed to be within a JSON object context (i.e. this provider should write fields and their values to the generator). Upon return, the generator should be within the same JSON object context.
- Specified by:
writeTo
in interfaceJsonProvider<ILoggingEvent>
- Parameters:
generator
- theJsonGenerator
to produce JSON contentevent
- the event to convert into JSON- Throws:
IOException
- if an I/O error occurs
-
setFieldNames
- Specified by:
setFieldNames
in interfaceFieldNamesAware<LogstashFieldNames>
-
getMessageSplitRegex
Write the message as a JSON array by splitting the message text using the specified regex.- Returns:
- The regex used to split the message text
-
setMessageSplitRegex
Write the message as a JSON array by splitting the message text using the specified regex.The allowed values are:
- Null/Empty : Disable message splitting. This is also the default behavior.
- Any valid regex : Use the specified regex.
SYSTEM
: Use the system-default line separator.UNIX
: Use\n
.WINDOWS
: Use\r\n
.
#+
, then the logging statement:log.info("First line##Second line###Third line")
will produce:{ ... "message": [ "First line", "Second line", "Third line" ], ... }
- Parameters:
messageSplitRegex
- The regex used to split the message text
-