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
  • Constructor Details

    • GlobalCustomFieldsJsonProvider

      public GlobalCustomFieldsJsonProvider()
  • Method Details

    • writeTo

      public void writeTo(JsonGenerator generator, Event event) throws IOException
      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 interface JsonProvider<Event extends DeferredProcessingAware>
      Parameters:
      generator - the JsonGenerator to produce JSON content
      event - 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 customFields JSON string. An ERROR status is emitted instead and no exception is thrown.

      Specified by:
      start in interface JsonProvider<Event extends DeferredProcessingAware>
      Overrides:
      start in class AbstractJsonProvider<Event extends DeferredProcessingAware>
    • setCustomFields

      public void setCustomFields(String customFields)
      Set the custom fields as a JSON string. The string will be parsed when the provider is start().
      Parameters:
      customFields - the custom fields as JSON string.
    • getCustomFields

      public String getCustomFields()
    • getCustomFieldsNode

      public ObjectNode getCustomFieldsNode()
    • setCustomFieldsNode

      @Deprecated public void setCustomFieldsNode(JsonNode customFields)
      Deprecated.
      Set the custom JSON fields. Must be a valid JsonNode that maps to a JSON object structure, i.e. an ObjectNode.
      Parameters:
      customFields - a JsonNode whose properties must be added as custom fields.
      Throws:
      IllegalArgumentException - if the argument is not a ObjectNode.
    • setCustomFieldsNode

      public void setCustomFieldsNode(ObjectNode customFields)
      Use the fields of the given ObjectNode (may be empty).
      Parameters:
      customFields - the JSON object whose fields as added as custom fields
    • setJsonFactory

      public void setJsonFactory(JsonFactory jsonFactory)
      Specified by:
      setJsonFactory in interface JsonFactoryAware