Class TextLogFormatterBuilder
java.lang.Object
com.linecorp.armeria.common.logging.TextLogFormatterBuilder
A builder implementation for
TextLogFormatter
.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a newly-created textLogFormatter
based on the properties of this builder.contentSanitizer
(BiFunction<? super RequestContext, Object, ? extends String> contentSanitizer) Sets theBiFunction
to use to sanitize request and response content before logging.headersSanitizer
(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends String> headersSanitizer) Sets theBiFunction
to use to sanitize request, response and trailers before logging.includeContext
(boolean includeContext) Sets whether to include stringifiedRequestContext
in the result ofLogFormatter.formatRequest(RequestOnlyLog)
andLogFormatter.formatResponse(RequestLog)
.requestContentSanitizer
(BiFunction<? super RequestContext, Object, ? extends String> requestContentSanitizer) Sets theBiFunction
to use to sanitize request content before logging.requestHeadersSanitizer
(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends String> requestHeadersSanitizer) Sets theBiFunction
to use to sanitize request headers before logging.requestTrailersSanitizer
(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends String> requestTrailersSanitizer) Sets theBiFunction
to use to sanitize request trailers before logging.responseContentSanitizer
(BiFunction<? super RequestContext, Object, ? extends String> responseContentSanitizer) Sets theBiFunction
to use to sanitize response content before logging.responseHeadersSanitizer
(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends String> responseHeadersSanitizer) Sets theBiFunction
to use to sanitize response headers before logging.responseTrailersSanitizer
(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends String> responseTrailersSanitizer) Sets theBiFunction
to use to sanitize response trailers before logging.
-
Method Details
-
includeContext
Sets whether to include stringifiedRequestContext
in the result ofLogFormatter.formatRequest(RequestOnlyLog)
andLogFormatter.formatResponse(RequestLog)
. The context is included by default. -
build
Returns a newly-created textLogFormatter
based on the properties of this builder. -
requestHeadersSanitizer
public TextLogFormatterBuilder requestHeadersSanitizer(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends String> requestHeadersSanitizer) Sets theBiFunction
to use to sanitize request headers before logging. It is common to have theBiFunction
that removes sensitive headers, likeCookie
, before logging. If unset, will not sanitize request headers.HeadersSanitizer<String> headersSanitizer = HeadersSanitizer .builderForText() .sensitiveHeaders("Authorization", "Cookie") ... .build(); LogFormatter .builderForText() .requestHeadersSanitizer(headersSanitizer) ...
- See Also:
-
responseHeadersSanitizer
public TextLogFormatterBuilder responseHeadersSanitizer(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends String> responseHeadersSanitizer) Sets theBiFunction
to use to sanitize response headers before logging. It is common to have theBiFunction
that removes sensitive headers, likeSet-Cookie
, before logging. If unset, will not sanitize response headers.HeadersSanitizer<String> headersSanitizer = HeadersSanitizer .builderForText() .sensitiveHeaders("Set-Cookie") ... .build(); LogFormatter .builderForText() .responseHeadersSanitizer(headersSanitizer) ...
- See Also:
-
requestTrailersSanitizer
public TextLogFormatterBuilder requestTrailersSanitizer(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends String> requestTrailersSanitizer) Sets theBiFunction
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) ...
- See Also:
-
responseTrailersSanitizer
public TextLogFormatterBuilder responseTrailersSanitizer(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends String> responseTrailersSanitizer) Sets theBiFunction
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) ...
- See Also:
-
headersSanitizer
public TextLogFormatterBuilder headersSanitizer(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends String> headersSanitizer) Sets theBiFunction
to use to sanitize request, response and trailers before logging. It is common to have theBiFunction
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 TextLogFormatterBuilder requestContentSanitizer(BiFunction<? super RequestContext, Object, ? extends String> requestContentSanitizer) Sets theBiFunction
to use to sanitize request content before logging. It is common to have theBiFunction
that removes sensitive content, such as an GPS location query, before logging. If unset, will not sanitize request content. -
responseContentSanitizer
public TextLogFormatterBuilder responseContentSanitizer(BiFunction<? super RequestContext, Object, ? extends String> responseContentSanitizer) Sets theBiFunction
to use to sanitize response content before logging. It is common to have theBiFunction
that removes sensitive content, such as an address, before logging. If unset, will not sanitize response content. -
contentSanitizer
public TextLogFormatterBuilder contentSanitizer(BiFunction<? super RequestContext, Object, ? extends String> contentSanitizer) Sets theBiFunction
to use to sanitize request and response content before logging. It is common to have theBiFunction
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:
-