Class ArgumentsJsonProvider

All Implemented Interfaces:
ContextAware, FieldNamesAware<LogstashFieldNames>, JsonProvider<ILoggingEvent>

public class ArgumentsJsonProvider extends AbstractFieldJsonProvider<ILoggingEvent> implements FieldNamesAware<LogstashFieldNames>
Include the logging event's ILoggingEvent.getArgumentArray() in the JSON output.

Arguments that are an instance of StructuredArgument will be output as specified by StructuredArgument.writeTo(JsonGenerator).

Non-StructuredArguments will be omitted unless includeNonStructuredArguments is true. When true, they will be included in the JSON output as separate fields whose names are nonStructuredArgumentsFieldPrefix plus the argument index. (For example, "arg0").

If the fieldName is non-null, then the arguments will be written to that field as a subobject. Otherwise, the arguments are written inline.
  • Constructor Details

    • ArgumentsJsonProvider

      public ArgumentsJsonProvider()
  • Method Details

    • writeTo

      public void writeTo(JsonGenerator generator, ILoggingEvent 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<ILoggingEvent>
      Parameters:
      generator - the JsonGenerator to produce JSON content
      event - the event to convert into JSON
      Throws:
      IOException - if an I/O error occurs
    • isIncludeStructuredArguments

      public boolean isIncludeStructuredArguments()
    • setIncludeStructuredArguments

      public void setIncludeStructuredArguments(boolean includeStructuredArguments)
    • isIncludeNonStructuredArguments

      public boolean isIncludeNonStructuredArguments()
    • setIncludeNonStructuredArguments

      public void setIncludeNonStructuredArguments(boolean includeNonStructuredArguments)
    • getNonStructuredArgumentsFieldPrefix

      public String getNonStructuredArgumentsFieldPrefix()
    • setNonStructuredArgumentsFieldPrefix

      public void setNonStructuredArgumentsFieldPrefix(String nonStructuredArgumentsFieldPrefix)
    • setFieldNames

      public void setFieldNames(LogstashFieldNames fieldNames)
      Specified by:
      setFieldNames in interface FieldNamesAware<LogstashFieldNames>