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(BiFunction<? super RequestContext,Object,?> contentSanitizer)
Sets theBiFunction
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(BiFunction<? super RequestContext,? super HttpHeaders,?> headersSanitizer)
Sets theBiFunction
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(String loggerName)
Sets the name of theLogger
to use when logging.LoggingDecoratorBuilder
logger(Logger logger)
Sets theLogger
to use when logging.protected BiFunction<? super RequestContext,Object,?>
requestContentSanitizer()
Returns theBiFunction
to use to sanitize request content before logging.LoggingDecoratorBuilder
requestContentSanitizer(BiFunction<? super RequestContext,Object,?> requestContentSanitizer)
Sets theBiFunction
to use to sanitize request content before logging.protected BiFunction<? super RequestContext,? super HttpHeaders,?>
requestHeadersSanitizer()
Returns theBiFunction
to use to sanitize request headers before logging.LoggingDecoratorBuilder
requestHeadersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,?> requestHeadersSanitizer)
Sets theBiFunction
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 BiFunction<? super RequestContext,? super HttpHeaders,?>
requestTrailersSanitizer()
Returns theBiFunction
to use to sanitize request trailers before logging.LoggingDecoratorBuilder
requestTrailersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,?> requestTrailersSanitizer)
Sets theBiFunction
to use to sanitize request trailers before logging.protected BiFunction<? super RequestContext,? super Throwable,?>
responseCauseSanitizer()
Returns theBiFunction
to use to sanitize response cause before logging.LoggingDecoratorBuilder
responseCauseSanitizer(BiFunction<? super RequestContext,? super Throwable,?> responseCauseSanitizer)
Sets theBiFunction
to use to sanitize a response cause before logging.protected BiFunction<? super RequestContext,Object,?>
responseContentSanitizer()
Returns theBiFunction
to use to sanitize response content before logging.LoggingDecoratorBuilder
responseContentSanitizer(BiFunction<? super RequestContext,Object,?> responseContentSanitizer)
Sets theBiFunction
to use to sanitize response content before logging.protected BiFunction<? super RequestContext,? super HttpHeaders,?>
responseHeadersSanitizer()
Returns theBiFunction
to use to sanitize response headers before logging.LoggingDecoratorBuilder
responseHeadersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,?> responseHeadersSanitizer)
Sets theBiFunction
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 BiFunction<? super RequestContext,? super HttpHeaders,?>
responseTrailersSanitizer()
Returns theFunction
to use to sanitize response trailers before logging.LoggingDecoratorBuilder
responseTrailersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,?> responseTrailersSanitizer)
Sets theBiFunction
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
Sets the name of theLogger
to use when logging. This method is a shortcut forthis.logger(LoggerFactory.getLogger(loggerName))
. -
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.DEBUG
. -
successfulResponseLogLevel
Sets theLogLevel
to use when logging successful responses (e.g., no unhandled exception). If unset, will useLogLevel.DEBUG
. -
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(BiFunction<? super RequestContext,? super HttpHeaders,?> 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. -
requestHeadersSanitizer
protected final BiFunction<? super RequestContext,? super HttpHeaders,?> requestHeadersSanitizer()Returns theBiFunction
to use to sanitize request headers before logging. -
responseHeadersSanitizer
public LoggingDecoratorBuilder responseHeadersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,?> 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. -
responseHeadersSanitizer
protected final BiFunction<? super RequestContext,? super HttpHeaders,?> responseHeadersSanitizer()Returns theBiFunction
to use to sanitize response headers before logging. -
requestTrailersSanitizer
public LoggingDecoratorBuilder requestTrailersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,?> requestTrailersSanitizer)Sets theBiFunction
to use to sanitize request trailers before logging. If unset, will not sanitize request trailers. -
requestTrailersSanitizer
protected final BiFunction<? super RequestContext,? super HttpHeaders,?> requestTrailersSanitizer()Returns theBiFunction
to use to sanitize request trailers before logging. -
responseTrailersSanitizer
public LoggingDecoratorBuilder responseTrailersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,?> responseTrailersSanitizer)Sets theBiFunction
to use to sanitize response trailers before logging. If unset, will not sanitize response trailers. -
responseTrailersSanitizer
protected final BiFunction<? super RequestContext,? super HttpHeaders,?> responseTrailersSanitizer()Returns theFunction
to use to sanitize response trailers before logging. -
headersSanitizer
public LoggingDecoratorBuilder headersSanitizer(BiFunction<? super RequestContext,? super HttpHeaders,?> 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:builder.requestHeadersSanitizer(headersSanitizer); builder.requestTrailersSanitizer(headersSanitizer); builder.responseHeadersSanitizer(headersSanitizer); builder.responseTrailersSanitizer(headersSanitizer);
-
requestContentSanitizer
public LoggingDecoratorBuilder requestContentSanitizer(BiFunction<? super RequestContext,Object,?> 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. -
requestContentSanitizer
Returns theBiFunction
to use to sanitize request content before logging. -
responseContentSanitizer
public LoggingDecoratorBuilder responseContentSanitizer(BiFunction<? super RequestContext,Object,?> 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. -
responseContentSanitizer
Returns theBiFunction
to use to sanitize response content before logging. -
contentSanitizer
public LoggingDecoratorBuilder contentSanitizer(BiFunction<? super RequestContext,Object,?> 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);
-
responseCauseSanitizer
public LoggingDecoratorBuilder responseCauseSanitizer(BiFunction<? super RequestContext,? super Throwable,?> responseCauseSanitizer)Sets theBiFunction
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 theBiFunction
. If unset, will not sanitize a response cause. -
responseCauseSanitizer
Returns theBiFunction
to use to sanitize response cause before logging. -
toString
-