Class LoggingClientBuilder
java.lang.Object
com.linecorp.armeria.common.logging.LoggingDecoratorBuilder
com.linecorp.armeria.client.logging.LoggingClientBuilder
Builds a new
LoggingClient
.-
Method Summary
Modifier and TypeMethodDescriptionbuild
(HttpClient delegate) Returns a newly-createdLoggingClient
decoratingdelegate
based on the properties of this builder.contentSanitizer
(BiFunction<? super RequestContext, Object, ? extends @Nullable Object> contentSanitizer) Deprecated.protected LoggingClientBuilder
defaultLogger
(Logger defaultLogger) Sets the logger that is used when neitherLoggingDecoratorBuilder.logWriter(LogWriter)
norLoggingDecoratorBuilder.logger(Logger)
is set.failureResponseLogLevel
(LogLevel failureResponseLogLevel) Deprecated.failureSampler
(Sampler<? super ClientRequestContext> sampler) Sets theSampler
that determines which failure request needs logging.failureSamplingRate
(float samplingRate) Sets the rate at which to sample failure requests to log.headersSanitizer
(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends @Nullable Object> headersSanitizer) Deprecated.Deprecated.Deprecated.Function
<? super HttpClient, LoggingClient> Returns a newly-createdLoggingClient
decorator based on the properties of this builder.requestContentSanitizer
(BiFunction<? super RequestContext, Object, ? extends @Nullable Object> requestContentSanitizer) Deprecated.requestHeadersSanitizer
(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends @Nullable Object> requestHeadersSanitizer) Deprecated.requestLogLevel
(LogLevel requestLogLevel) Deprecated.requestLogLevel
(Class<? extends Throwable> clazz, LogLevel requestLogLevel) Deprecated.requestLogLevelMapper
(RequestLogLevelMapper requestLogLevelMapper) Deprecated.requestLogLevelMapper
(Function<? super RequestOnlyLog, LogLevel> requestLogLevelMapper) Deprecated.requestTrailersSanitizer
(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends @Nullable Object> requestTrailersSanitizer) Deprecated.responseCauseFilter
(Predicate<Throwable> responseCauseFilter) Deprecated.responseCauseSanitizer
(BiFunction<? super RequestContext, ? super Throwable, ? extends @Nullable Object> responseCauseSanitizer) Deprecated.responseContentSanitizer
(BiFunction<? super RequestContext, Object, ? extends @Nullable Object> responseContentSanitizer) Deprecated.responseHeadersSanitizer
(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends @Nullable Object> responseHeadersSanitizer) Deprecated.responseLogLevel
(HttpStatusClass statusClass, LogLevel logLevel) Deprecated.responseLogLevel
(HttpStatus status, LogLevel logLevel) Deprecated.responseLogLevel
(Class<? extends Throwable> clazz, LogLevel logLevel) Deprecated.responseLogLevelMapper
(ResponseLogLevelMapper responseLogLevelMapper) Deprecated.responseLogLevelMapper
(Function<? super RequestLog, LogLevel> responseLogLevelMapper) Deprecated.responseTrailersSanitizer
(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends @Nullable Object> responseTrailersSanitizer) Deprecated.sampler
(Sampler<? super ClientRequestContext> sampler) Sets theSampler
that determines which request needs logging.samplingRate
(float samplingRate) Sets the rate at which to sample requests to log.successfulResponseLogLevel
(LogLevel successfulResponseLogLevel) Deprecated.successSampler
(Sampler<? super ClientRequestContext> sampler) Sets theSampler
that determines which success request needs logging.successSamplingRate
(float samplingRate) Sets the rate at which to sample success requests to log.Methods inherited from class com.linecorp.armeria.common.logging.LoggingDecoratorBuilder
logger, logWriter, requestContentSanitizer, requestHeadersSanitizer, requestLogLevelMapper, requestTrailersSanitizer, responseCauseSanitizer, responseContentSanitizer, responseHeadersSanitizer, responseLogLevelMapper, responseTrailersSanitizer
-
Method Details
-
build
Returns a newly-createdLoggingClient
decoratingdelegate
based on the properties of this builder. -
newDecorator
Returns a newly-createdLoggingClient
decorator based on the properties of this builder. -
defaultLogger
Description copied from class:LoggingDecoratorBuilder
Sets the logger that is used when neitherLoggingDecoratorBuilder.logWriter(LogWriter)
norLoggingDecoratorBuilder.logger(Logger)
is set.- Overrides:
defaultLogger
in classLoggingDecoratorBuilder
-
samplingRate
Sets the rate at which to sample requests to log. Any number between0.0
and1.0
will cause a random sample of the requests to be logged. This method sets both success and failure sampling rate. UsesuccessSamplingRate(float)
andfailureSamplingRate(float)
if you want to specify a different sampling rate for each case. -
sampler
Sets theSampler
that determines which request needs logging. -
successSampler
Sets theSampler
that determines which success request needs logging. -
successSamplingRate
Sets the rate at which to sample success requests to log. Any number between0.0
and1.0
will cause a random sample of the success requests to be logged. -
failureSampler
Sets theSampler
that determines which failure request needs logging. -
failureSamplingRate
Sets the rate at which to sample failure requests to log. Any number between0.0
and1.0
will cause a random sample of the failure requests to be logged. -
logWriter
Description copied from class:LoggingDecoratorBuilder
Sets theLogWriter
which write aRequestOnlyLog
orRequestLog
. By defaultLogWriter.of()
will be used.- Overrides:
logWriter
in classLoggingDecoratorBuilder
-
logger
Deprecated.Description copied from class:LoggingDecoratorBuilder
- Overrides:
logger
in classLoggingDecoratorBuilder
-
logger
Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets the name of theLogger
to use when logging. This method is a shortcut forthis.logger(LoggerFactory.getLogger(loggerName))
.- Overrides:
logger
in classLoggingDecoratorBuilder
-
requestLogLevel
Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets theLogLevel
to use when logging requests. If unset, will useLogLevel.DEBUG
.- Overrides:
requestLogLevel
in classLoggingDecoratorBuilder
-
requestLogLevel
@Deprecated public LoggingClientBuilder requestLogLevel(Class<? extends Throwable> clazz, LogLevel requestLogLevel) Deprecated.Description copied from class:LoggingDecoratorBuilder
- Overrides:
requestLogLevel
in classLoggingDecoratorBuilder
-
requestLogLevelMapper
@Deprecated public LoggingClientBuilder requestLogLevelMapper(Function<? super RequestOnlyLog, LogLevel> requestLogLevelMapper) Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets theFunction
to use when mapping the log level of request logs.- Overrides:
requestLogLevelMapper
in classLoggingDecoratorBuilder
-
requestLogLevelMapper
@Deprecated public LoggingClientBuilder requestLogLevelMapper(RequestLogLevelMapper requestLogLevelMapper) Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets theRequestLogLevelMapper
to use when mapping the log level of request logs.- Overrides:
requestLogLevelMapper
in classLoggingDecoratorBuilder
-
responseLogLevel
Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets theLogLevel
to use when logging responses whose status is equal to the specifiedHttpStatus
.- Overrides:
responseLogLevel
in classLoggingDecoratorBuilder
-
responseLogLevel
@Deprecated public LoggingClientBuilder responseLogLevel(HttpStatusClass statusClass, LogLevel logLevel) Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets theLogLevel
to use when logging responses whose status belongs to the specifiedHttpStatusClass
.- Overrides:
responseLogLevel
in classLoggingDecoratorBuilder
-
responseLogLevel
@Deprecated public LoggingClientBuilder responseLogLevel(Class<? extends Throwable> clazz, LogLevel logLevel) Deprecated.Description copied from class:LoggingDecoratorBuilder
- Overrides:
responseLogLevel
in classLoggingDecoratorBuilder
-
successfulResponseLogLevel
@Deprecated public LoggingClientBuilder successfulResponseLogLevel(LogLevel successfulResponseLogLevel) Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets theLogLevel
to use when logging successful responses (e.g., no unhandled exception).LogLevel.DEBUG
will be used by default.- Overrides:
successfulResponseLogLevel
in classLoggingDecoratorBuilder
-
failureResponseLogLevel
Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets theLogLevel
to use when logging failure responses (e.g., failed with an exception).LogLevel.WARN
will be used by default.- Overrides:
failureResponseLogLevel
in classLoggingDecoratorBuilder
-
responseLogLevelMapper
@Deprecated public LoggingClientBuilder responseLogLevelMapper(Function<? super RequestLog, LogLevel> responseLogLevelMapper) Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets theFunction
to use when mapping the log level of response logs.- Overrides:
responseLogLevelMapper
in classLoggingDecoratorBuilder
-
responseLogLevelMapper
@Deprecated public LoggingClientBuilder responseLogLevelMapper(ResponseLogLevelMapper responseLogLevelMapper) Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets theResponseLogLevelMapper
to use when mapping the log level of response logs.- Overrides:
responseLogLevelMapper
in classLoggingDecoratorBuilder
-
requestHeadersSanitizer
@Deprecated public LoggingClientBuilder requestHeadersSanitizer(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends @Nullable Object> requestHeadersSanitizer) Deprecated.Description copied from class:LoggingDecoratorBuilder
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.- Overrides:
requestHeadersSanitizer
in classLoggingDecoratorBuilder
-
responseHeadersSanitizer
@Deprecated public LoggingClientBuilder responseHeadersSanitizer(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends @Nullable Object> responseHeadersSanitizer) Deprecated.Description copied from class:LoggingDecoratorBuilder
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.- Overrides:
responseHeadersSanitizer
in classLoggingDecoratorBuilder
-
requestTrailersSanitizer
@Deprecated public LoggingClientBuilder requestTrailersSanitizer(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends @Nullable Object> requestTrailersSanitizer) Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets theBiFunction
to use to sanitize request trailers before logging. If unset, will not sanitize request trailers.- Overrides:
requestTrailersSanitizer
in classLoggingDecoratorBuilder
-
responseTrailersSanitizer
@Deprecated public LoggingClientBuilder responseTrailersSanitizer(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends @Nullable Object> responseTrailersSanitizer) Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets theBiFunction
to use to sanitize response trailers before logging. If unset, will not sanitize response trailers.- Overrides:
responseTrailersSanitizer
in classLoggingDecoratorBuilder
-
headersSanitizer
@Deprecated public LoggingClientBuilder headersSanitizer(BiFunction<? super RequestContext, ? super HttpHeaders, ? extends @Nullable Object> headersSanitizer) Deprecated.Description copied from class:LoggingDecoratorBuilder
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);
- Overrides:
headersSanitizer
in classLoggingDecoratorBuilder
- See Also:
-
requestContentSanitizer
@Deprecated public LoggingClientBuilder requestContentSanitizer(BiFunction<? super RequestContext, Object, ? extends @Nullable Object> requestContentSanitizer) Deprecated.Description copied from class:LoggingDecoratorBuilder
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.- Overrides:
requestContentSanitizer
in classLoggingDecoratorBuilder
-
responseContentSanitizer
@Deprecated public LoggingClientBuilder responseContentSanitizer(BiFunction<? super RequestContext, Object, ? extends @Nullable Object> responseContentSanitizer) Deprecated.Description copied from class:LoggingDecoratorBuilder
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.- Overrides:
responseContentSanitizer
in classLoggingDecoratorBuilder
-
contentSanitizer
@Deprecated public LoggingClientBuilder contentSanitizer(BiFunction<? super RequestContext, Object, ? extends @Nullable Object> contentSanitizer) Deprecated.Description copied from class:LoggingDecoratorBuilder
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);
- Overrides:
contentSanitizer
in classLoggingDecoratorBuilder
- See Also:
-
responseCauseSanitizer
@Deprecated public LoggingClientBuilder responseCauseSanitizer(BiFunction<? super RequestContext, ? super Throwable, ? extends @Nullable Object> responseCauseSanitizer) Deprecated.Description copied from class:LoggingDecoratorBuilder
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.Note that this method is no longer supported. You must use
LogWriterBuilder.responseCauseFilter(BiPredicate)
.- Overrides:
responseCauseSanitizer
in classLoggingDecoratorBuilder
-
responseCauseFilter
@Deprecated public LoggingClientBuilder responseCauseFilter(Predicate<Throwable> responseCauseFilter) Deprecated.Description copied from class:LoggingDecoratorBuilder
Sets thePredicate
used for evaluating whether to log the response cause or not. You can prevent logging the response cause by returningtrue
in thePredicate
. By default, the response cause will always be logged.- Overrides:
responseCauseFilter
in classLoggingDecoratorBuilder
-