Class LoggingDecoratorBuilder
java.lang.Object
com.linecorp.armeria.common.logging.LoggingDecoratorBuilder
- Direct Known Subclasses:
LoggingClientBuilder
,LoggingRpcClientBuilder
,LoggingServiceBuilder
public abstract class LoggingDecoratorBuilder extends Object
Builds a new logging decorator.
-
Constructor Summary
Constructors Constructor Description LoggingDecoratorBuilder()
-
Method Summary
Modifier and Type Method Description LoggingDecoratorBuilder
contentSanitizer(Function<Object,?> contentSanitizer)
Sets theFunction
to use to sanitize request and response content before logging.LoggingDecoratorBuilder
failureResponseLogLevel(LogLevel failedResponseLogLevel)
Sets theLogLevel
to use when logging failure responses (e.g., failed with an exception).LoggingDecoratorBuilder
headersSanitizer(Function<? super HttpHeaders,?> headersSanitizer)
Sets theFunction
to use to sanitize request, response and trailers before logging.protected Logger
logger()
Returns theLogger
the user specified to use, ornull
if not set and a default logger should be used.LoggingDecoratorBuilder
logger(Logger logger)
Sets theLogger
to use when logging.protected Function<Object,?>
requestContentSanitizer()
Returns theFunction
to use to sanitize request content before logging.LoggingDecoratorBuilder
requestContentSanitizer(Function<Object,?> requestContentSanitizer)
Sets theFunction
to use to sanitize request content before logging.protected Function<? super HttpHeaders,?>
requestHeadersSanitizer()
Returns theFunction
to use to sanitize request headers before logging.LoggingDecoratorBuilder
requestHeadersSanitizer(Function<? super HttpHeaders,?> requestHeadersSanitizer)
Sets theFunction
to use to sanitize request headers before logging.LoggingDecoratorBuilder
requestLogLevel(LogLevel requestLogLevel)
Sets theLogLevel
to use when logging requests.protected Function<? super RequestOnlyLog,LogLevel>
requestLogLevelMapper()
Returns theLogLevel
to use when logging request logs.LoggingDecoratorBuilder
requestLogLevelMapper(Function<? super RequestOnlyLog,LogLevel> requestLogLevelMapper)
Sets theFunction
to use when mapping the log level of request logs.protected Function<? super HttpHeaders,?>
requestTrailersSanitizer()
Returns theFunction
to use to sanitize request trailers before logging.LoggingDecoratorBuilder
requestTrailersSanitizer(Function<? super HttpHeaders,?> requestTrailersSanitizer)
Sets theFunction
to use to sanitize request trailers before logging.protected Function<? super Throwable,?>
responseCauseSanitizer()
Returns theFunction
to use to sanitize response cause before logging.LoggingDecoratorBuilder
responseCauseSanitizer(Function<? super Throwable,?> responseCauseSanitizer)
Sets theFunction
to use to sanitize a response cause before logging.protected Function<Object,?>
responseContentSanitizer()
Returns theFunction
to use to sanitize response content before logging.LoggingDecoratorBuilder
responseContentSanitizer(Function<Object,?> responseContentSanitizer)
Sets theFunction
to use to sanitize response content before logging.protected Function<? super HttpHeaders,?>
responseHeadersSanitizer()
Returns theFunction
to use to sanitize response headers before logging.LoggingDecoratorBuilder
responseHeadersSanitizer(Function<? super HttpHeaders,?> responseHeadersSanitizer)
Sets theFunction
to use to sanitize response headers before logging.protected Function<? super RequestLog,LogLevel>
responseLogLevelMapper()
Returns theLogLevel
to use when logging response logs.LoggingDecoratorBuilder
responseLogLevelMapper(Function<? super RequestLog,LogLevel> responseLogLevelMapper)
Sets theFunction
to use when mapping the log level of response logs.protected Function<? super HttpHeaders,?>
responseTrailersSanitizer()
Returns theFunction
to use to sanitize response trailers before logging.LoggingDecoratorBuilder
responseTrailersSanitizer(Function<? super HttpHeaders,?> responseTrailersSanitizer)
Sets theFunction
to use to sanitize response trailers before logging.LoggingDecoratorBuilder
successfulResponseLogLevel(LogLevel successfulResponseLogLevel)
Sets theLogLevel
to use when logging successful responses (e.g., no unhandled exception).String
toString()
-
Constructor Details
-
LoggingDecoratorBuilder
public LoggingDecoratorBuilder()
-
-
Method Details
-
logger
-
logger
Returns theLogger
the user specified to use, ornull
if not set and a default logger should be used. -
requestLogLevel
Sets theLogLevel
to use when logging requests. If unset, will useLogLevel.TRACE
. -
successfulResponseLogLevel
Sets theLogLevel
to use when logging successful responses (e.g., no unhandled exception). If unset, will useLogLevel.TRACE
. -
failureResponseLogLevel
Sets theLogLevel
to use when logging failure responses (e.g., failed with an exception). If unset, will useLogLevel.WARN
. The request will be logged too if it was not otherwise. -
requestLogLevelMapper
public LoggingDecoratorBuilder requestLogLevelMapper(Function<? super RequestOnlyLog,LogLevel> requestLogLevelMapper)Sets theFunction
to use when mapping the log level of request logs. -
requestLogLevelMapper
Returns theLogLevel
to use when logging request logs. -
responseLogLevelMapper
public LoggingDecoratorBuilder responseLogLevelMapper(Function<? super RequestLog,LogLevel> responseLogLevelMapper)Sets theFunction
to use when mapping the log level of response logs. -
responseLogLevelMapper
Returns theLogLevel
to use when logging response logs. -
requestHeadersSanitizer
public LoggingDecoratorBuilder requestHeadersSanitizer(Function<? super HttpHeaders,?> requestHeadersSanitizer)Sets theFunction
to use to sanitize request headers before logging. It is common to have theFunction
that removes sensitive headers, likeCookie
, before logging. If unset, will useFunction.identity()
. -
requestHeadersSanitizer
Returns theFunction
to use to sanitize request headers before logging. -
responseHeadersSanitizer
public LoggingDecoratorBuilder responseHeadersSanitizer(Function<? super HttpHeaders,?> responseHeadersSanitizer)Sets theFunction
to use to sanitize response headers before logging. It is common to have theFunction
that removes sensitive headers, likeSet-Cookie
, before logging. If unset, will useFunction.identity()
. -
responseHeadersSanitizer
Returns theFunction
to use to sanitize response headers before logging. -
requestTrailersSanitizer
public LoggingDecoratorBuilder requestTrailersSanitizer(Function<? super HttpHeaders,?> requestTrailersSanitizer)Sets theFunction
to use to sanitize request trailers before logging. If unset, will useFunction.identity()
. -
requestTrailersSanitizer
Returns theFunction
to use to sanitize request trailers before logging. -
responseTrailersSanitizer
public LoggingDecoratorBuilder responseTrailersSanitizer(Function<? super HttpHeaders,?> responseTrailersSanitizer)Sets theFunction
to use to sanitize response trailers before logging. If unset, will useFunction.identity()
. -
responseTrailersSanitizer
Returns theFunction
to use to sanitize response trailers before logging. -
headersSanitizer
Sets theFunction
to use to sanitize request, response and trailers before logging. It is common to have theFunction
that removes sensitive headers, like"Cookie"
and"Set-Cookie"
, before logging. This method is a shortcut for:builder.requestHeadersSanitizer(headersSanitizer); builder.requestTrailersSanitizer(headersSanitizer); builder.responseHeadersSanitizer(headersSanitizer); builder.responseTrailersSanitizer(headersSanitizer);
-
requestContentSanitizer
public LoggingDecoratorBuilder requestContentSanitizer(Function<Object,?> requestContentSanitizer)Sets theFunction
to use to sanitize request content before logging. It is common to have theFunction
that removes sensitive content, such as an GPS location query, before logging. If unset, will useFunction.identity()
. -
requestContentSanitizer
Returns theFunction
to use to sanitize request content before logging. -
responseContentSanitizer
public LoggingDecoratorBuilder responseContentSanitizer(Function<Object,?> responseContentSanitizer)Sets theFunction
to use to sanitize response content before logging. It is common to have theFunction
that removes sensitive content, such as an address, before logging. If unset, will useFunction.identity()
. -
responseContentSanitizer
Returns theFunction
to use to sanitize response content before logging. -
contentSanitizer
Sets theFunction
to use to sanitize request and response content before logging. It is common to have theFunction
that removes sensitive content, such as an GPS location query and an address, before logging. If unset, will useFunction.identity()
. This method is a shortcut for:builder.requestContentSanitizer(contentSanitizer); builder.responseContentSanitizer(contentSanitizer);
-
responseCauseSanitizer
public LoggingDecoratorBuilder responseCauseSanitizer(Function<? super Throwable,?> responseCauseSanitizer)Sets theFunction
to use to sanitize a response cause before logging. You can sanitize the stack trace of the exception to remove sensitive information, or prevent from logging the stack trace completely by returningnull
in theFunction
. If unset, will useFunction.identity()
. -
responseCauseSanitizer
Returns theFunction
to use to sanitize response cause before logging. -
toString
-