Package com.azure.core.http.policy
Class HttpLogOptions
- java.lang.Object
-
- com.azure.core.http.policy.HttpLogOptions
-
public class HttpLogOptions extends Object
The log configurations for HTTP messages.
-
-
Constructor Summary
Constructors Constructor Description HttpLogOptions()
Creates a new instance that does not log any information about HTTP requests or responses.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description HttpLogOptions
addAllowedHeaderName(String allowedHeaderName)
Sets the given whitelisted header to the default header set that should be logged.HttpLogOptions
addAllowedQueryParamName(String allowedQueryParamName)
Sets the given whitelisted query param that should be logged.Set<String>
getAllowedHeaderNames()
Gets the whitelisted headers that should be logged.Set<String>
getAllowedQueryParamNames()
Gets the whitelisted query parameters.String
getApplicationId()
Deprecated.UseClientOptions
to configureapplicationId
.HttpLogDetailLevel
getLogLevel()
Gets the level of detail to log on HTTP messages.HttpRequestLogger
getRequestLogger()
Gets theHttpRequestLogger
that will be used to log HTTP requests.HttpResponseLogger
getResponseLogger()
Gets theHttpResponseLogger
that will be used to log HTTP responses.boolean
isPrettyPrintBody()
Gets flag to allow pretty printing of message bodies.HttpLogOptions
setAllowedHeaderNames(Set<String> allowedHeaderNames)
Sets the given whitelisted headers that should be logged.HttpLogOptions
setAllowedQueryParamNames(Set<String> allowedQueryParamNames)
Sets the given whitelisted query params to be displayed in the logging info.HttpLogOptions
setApplicationId(String applicationId)
Deprecated.UseClientOptions
to configureapplicationId
.HttpLogOptions
setLogLevel(HttpLogDetailLevel logLevel)
Sets the level of detail to log on Http messages.HttpLogOptions
setPrettyPrintBody(boolean prettyPrintBody)
Sets flag to allow pretty printing of message bodies.HttpLogOptions
setRequestLogger(HttpRequestLogger requestLogger)
Sets theHttpRequestLogger
that will be used to log HTTP requests.HttpLogOptions
setResponseLogger(HttpResponseLogger responseLogger)
Sets theHttpResponseLogger
that will be used to log HTTP responses.
-
-
-
Method Detail
-
getLogLevel
public HttpLogDetailLevel getLogLevel()
Gets the level of detail to log on HTTP messages.- Returns:
- The
HttpLogDetailLevel
.
-
setLogLevel
public HttpLogOptions setLogLevel(HttpLogDetailLevel logLevel)
Sets the level of detail to log on Http messages.If logLevel is not provided, default value of
HttpLogDetailLevel.NONE
is set.- Parameters:
logLevel
- TheHttpLogDetailLevel
.- Returns:
- The updated HttpLogOptions object.
-
getAllowedHeaderNames
public Set<String> getAllowedHeaderNames()
Gets the whitelisted headers that should be logged.- Returns:
- The list of whitelisted headers.
-
setAllowedHeaderNames
public HttpLogOptions setAllowedHeaderNames(Set<String> allowedHeaderNames)
Sets the given whitelisted headers that should be logged.This method sets the provided header names to be the whitelisted header names which will be logged for all HTTP requests and responses, overwriting any previously configured headers. Additionally, users can use
addAllowedHeaderName(String)
orgetAllowedHeaderNames()
to add or remove more headers names to the existing set of allowed header names.- Parameters:
allowedHeaderNames
- The list of whitelisted header names from the user.- Returns:
- The updated HttpLogOptions object.
-
addAllowedHeaderName
public HttpLogOptions addAllowedHeaderName(String allowedHeaderName)
Sets the given whitelisted header to the default header set that should be logged.- Parameters:
allowedHeaderName
- The whitelisted header name from the user.- Returns:
- The updated HttpLogOptions object.
- Throws:
NullPointerException
- IfallowedHeaderName
isnull
.
-
getAllowedQueryParamNames
public Set<String> getAllowedQueryParamNames()
Gets the whitelisted query parameters.- Returns:
- The list of whitelisted query parameters.
-
setAllowedQueryParamNames
public HttpLogOptions setAllowedQueryParamNames(Set<String> allowedQueryParamNames)
Sets the given whitelisted query params to be displayed in the logging info.- Parameters:
allowedQueryParamNames
- The list of whitelisted query params from the user.- Returns:
- The updated HttpLogOptions object.
-
addAllowedQueryParamName
public HttpLogOptions addAllowedQueryParamName(String allowedQueryParamName)
Sets the given whitelisted query param that should be logged.- Parameters:
allowedQueryParamName
- The whitelisted query param name from the user.- Returns:
- The updated HttpLogOptions object.
- Throws:
NullPointerException
- IfallowedQueryParamName
isnull
.
-
getApplicationId
@Deprecated public String getApplicationId()
Deprecated.UseClientOptions
to configureapplicationId
.Gets the application specific id.- Returns:
- The application specific id.
-
setApplicationId
@Deprecated public HttpLogOptions setApplicationId(String applicationId)
Deprecated.UseClientOptions
to configureapplicationId
.Sets the custom application specific id supplied by the user of the client library.- Parameters:
applicationId
- The user specified application id.- Returns:
- The updated HttpLogOptions object.
- Throws:
IllegalArgumentException
- IfapplicationId
contains spaces or is larger than 24 characters in length.
-
isPrettyPrintBody
public boolean isPrettyPrintBody()
Gets flag to allow pretty printing of message bodies.- Returns:
- true if pretty printing of message bodies is allowed.
-
setPrettyPrintBody
public HttpLogOptions setPrettyPrintBody(boolean prettyPrintBody)
Sets flag to allow pretty printing of message bodies.- Parameters:
prettyPrintBody
- If true, pretty prints message bodies when logging. If the detailLevel does not include body logging, this flag does nothing.- Returns:
- The updated HttpLogOptions object.
-
getRequestLogger
public HttpRequestLogger getRequestLogger()
Gets theHttpRequestLogger
that will be used to log HTTP requests.A default
HttpRequestLogger
will be used if one isn't supplied.- Returns:
- The
HttpRequestLogger
that will be used to log HTTP requests.
-
setRequestLogger
public HttpLogOptions setRequestLogger(HttpRequestLogger requestLogger)
Sets theHttpRequestLogger
that will be used to log HTTP requests.A default
HttpRequestLogger
will be used if one isn't supplied.- Parameters:
requestLogger
- TheHttpRequestLogger
that will be used to log HTTP requests.- Returns:
- The updated HttpLogOptions object.
-
getResponseLogger
public HttpResponseLogger getResponseLogger()
Gets theHttpResponseLogger
that will be used to log HTTP responses.A default
HttpResponseLogger
will be used if one isn't supplied.- Returns:
- The
HttpResponseLogger
that will be used to log HTTP responses.
-
setResponseLogger
public HttpLogOptions setResponseLogger(HttpResponseLogger responseLogger)
Sets theHttpResponseLogger
that will be used to log HTTP responses.A default
HttpResponseLogger
will be used if one isn't supplied.- Parameters:
responseLogger
- TheHttpResponseLogger
that will be used to log HTTP responses.- Returns:
- The updated HttpLogOptions object.
-
-