Class GlobalCustomFieldsJsonProvider<Event extends DeferredProcessingAware>
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
net.logstash.logback.composite.AbstractJsonProvider<Event>
net.logstash.logback.composite.GlobalCustomFieldsJsonProvider<Event>
- All Implemented Interfaces:
ContextAware, JsonProvider<Event>, ObjectMapperAware
public class GlobalCustomFieldsJsonProvider<Event extends DeferredProcessingAware>
extends AbstractJsonProvider<Event>
implements ObjectMapperAware
-
Field Summary
Fields inherited from class ContextAwareBase
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetCustomFields(String customFields) Set the custom fields as a JSON string.voidsetCustomFieldsNode(JsonNode customFields) Deprecated.voidsetCustomFieldsNode(ObjectNode customFields) Use the fields of the givenObjectNode(may be empty).voidsetObjectMapper(ObjectMapper objectMapper) voidstart()Start the provider.voidwriteTo(JsonGenerator generator, Event event) Writes information about the event, to the given generator.Methods inherited from class AbstractJsonProvider
assertIsStarted, isStarted, prepareForDeferredProcessing, stopMethods inherited from class ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Constructor Details
-
GlobalCustomFieldsJsonProvider
public GlobalCustomFieldsJsonProvider()
-
-
Method Details
-
writeTo
Description copied from interface:JsonProviderWrites 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:
writeToin interfaceJsonProvider<Event extends DeferredProcessingAware>- Parameters:
generator- theJsonGeneratorto produce JSON contentevent- the event to convert into JSON
-
start
public void start()Start the provider.The provider is started even when it fails to parse the
customFieldsJSON string. An ERROR status is emitted instead and no exception is thrown.- Specified by:
startin interfaceJsonProvider<Event extends DeferredProcessingAware>- Overrides:
startin classAbstractJsonProvider<Event extends DeferredProcessingAware>
-
setCustomFields
-
getCustomFields
-
getCustomFieldsNode
-
setCustomFieldsNode
Deprecated.usesetCustomFieldsNode(ObjectNode)instead.Set the custom JSON fields. Must be a valid JsonNode that maps to a JSON object structure, i.e. anObjectNode.- Parameters:
customFields- aJsonNodewhose properties must be added as custom fields.- Throws:
IllegalArgumentException- if the argument is not aObjectNode.
-
setCustomFieldsNode
Use the fields of the givenObjectNode(may be empty).- Parameters:
customFields- the JSON object whose fields as added as custom fields
-
setObjectMapper
- Specified by:
setObjectMapperin interfaceObjectMapperAware
-
setCustomFieldsNode(ObjectNode)instead.