Module logstash.logback.encoder
Package net.logstash.logback.composite
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,JsonFactoryAware,JsonProvider<Event>
public class GlobalCustomFieldsJsonProvider<Event extends DeferredProcessingAware>
extends AbstractJsonProvider<Event>
implements JsonFactoryAware
-
Field Summary
Fields inherited from class ch.qos.logback.core.spi.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).voidsetJsonFactory(JsonFactory jsonFactory) voidstart()Start the provider.voidwriteTo(JsonGenerator generator, Event event) Writes information about the event, to the given generator.Methods inherited from class net.logstash.logback.composite.AbstractJsonProvider
assertIsStarted, isStarted, prepareForDeferredProcessing, stopMethods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ch.qos.logback.core.spi.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- Throws:
IOException- if an I/O error occurs
-
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
Set the custom fields as a JSON string. The string will be parsed when the provider isstart().- Parameters:
customFields- the custom fields as JSON string.
-
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
-
setJsonFactory
- Specified by:
setJsonFactoryin interfaceJsonFactoryAware
-
setCustomFieldsNode(ObjectNode)instead.