Class JsonLogFormatterBuilder

java.lang.Object
com.linecorp.armeria.common.logging.JsonLogFormatterBuilder

@UnstableApi public final class JsonLogFormatterBuilder extends Object
A builder implementation for JsonLogFormatter.
  • Method Details

    • objectMapper

      public JsonLogFormatterBuilder objectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Sets the ObjectMapper that will be used to convert an object into a JSON format message.
    • requestHeadersSanitizer

      public JsonLogFormatterBuilder requestHeadersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,? extends @Nullable com.fasterxml.jackson.databind.JsonNode> requestHeadersSanitizer)
      Sets the BiFunction to use to sanitize request headers before logging. It is common to have the BiFunction that removes sensitive headers, like Cookie, before logging. If unset, will not sanitize request headers.
      
       HeadersSanitizer<String> headersSanitizer =
         HeadersSanitizer
           .builderForText()
           .sensitiveHeaders("Authorization", "Cookie")
           ...
           .build();
      
        LogFormatter
          .builderForText()
          .requestHeadersSanitizer(headersSanitizer)
          ...
       
    • responseHeadersSanitizer

      public JsonLogFormatterBuilder responseHeadersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,? extends @Nullable com.fasterxml.jackson.databind.JsonNode> responseHeadersSanitizer)
      Sets the BiFunction to use to sanitize response headers before logging. It is common to have the BiFunction that removes sensitive headers, like Set-Cookie, before logging. If unset, will not sanitize response headers.
      
       HeadersSanitizer<String> headersSanitizer =
         HeadersSanitizer
           .builderForText()
           .sensitiveHeaders("Set-Cookie")
           ...
           .build();
      
        LogFormatter
          .builderForText()
          .responseHeadersSanitizer(headersSanitizer)
          ...
       
    • requestTrailersSanitizer

      public JsonLogFormatterBuilder requestTrailersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,? extends @Nullable com.fasterxml.jackson.databind.JsonNode> requestTrailersSanitizer)
      Sets the BiFunction to use to sanitize request trailers before logging. If unset, will not sanitize request trailers.
      
       HeadersSanitizer<String> headersSanitizer =
         HeadersSanitizer
           .builderForText()
           .sensitiveHeaders("...")
           ...
           .build();
      
        LogFormatter
          .builderForText()
          .requestTrailersSanitizer(headersSanitizer)
          ...
       
    • responseTrailersSanitizer

      public JsonLogFormatterBuilder responseTrailersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,? extends @Nullable com.fasterxml.jackson.databind.JsonNode> responseTrailersSanitizer)
      Sets the BiFunction to use to sanitize response trailers before logging. If unset, will not sanitize response trailers.
      
       HeadersSanitizer<String> headersSanitizer =
         HeadersSanitizer
           .builderForText()
           .sensitiveHeaders("...")
           ...
           .build();
      
        LogFormatter
          .builderForText()
          .responseTrailersSanitizer(headersSanitizer)
          ...
       
    • headersSanitizer

      public JsonLogFormatterBuilder headersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,? extends @Nullable com.fasterxml.jackson.databind.JsonNode> headersSanitizer)
      Sets the BiFunction to use to sanitize request, response and trailers before logging. It is common to have the BiFunction that removes sensitive headers, like "Cookie" and "Set-Cookie", before logging. This method is a shortcut for:
      
       HeadersSanitizer<String> headersSanitizer =
         HeadersSanitizer
           .builderForText()
           .sensitiveHeaders("...")
           ...
           .build();
      
       builder.requestHeadersSanitizer(headersSanitizer);
       builder.requestTrailersSanitizer(headersSanitizer);
       builder.responseHeadersSanitizer(headersSanitizer);
       builder.responseTrailersSanitizer(headersSanitizer);
       
      See Also:
    • requestContentSanitizer

      public JsonLogFormatterBuilder requestContentSanitizer(BiFunction<? super RequestContext,Object,? extends @Nullable com.fasterxml.jackson.databind.JsonNode> requestContentSanitizer)
      Sets the BiFunction to use to sanitize request content before logging. It is common to have the BiFunction that removes sensitive content, such as an GPS location query, before logging. If unset, will not sanitize request content.
    • responseContentSanitizer

      public JsonLogFormatterBuilder responseContentSanitizer(BiFunction<? super RequestContext,Object,? extends @Nullable com.fasterxml.jackson.databind.JsonNode> responseContentSanitizer)
      Sets the BiFunction to use to sanitize response content before logging. It is common to have the BiFunction that removes sensitive content, such as an address, before logging. If unset, will not sanitize response content.
    • contentSanitizer

      public JsonLogFormatterBuilder contentSanitizer(BiFunction<? super RequestContext,Object,? extends @Nullable com.fasterxml.jackson.databind.JsonNode> contentSanitizer)
      Sets the BiFunction to use to sanitize request and response content before logging. It is common to have the BiFunction that removes sensitive content, such as an GPS location query and an address, before logging. If unset, will not sanitize content. This method is a shortcut for:
      
       builder.requestContentSanitizer(contentSanitizer);
       builder.responseContentSanitizer(contentSanitizer);
       
      See Also:
    • build

      public LogFormatter build()
      Returns a newly-created JSON LogFormatter based on the properties of this builder.