共用方式為


HttpLogDetailLevel Enum

  • java.lang.Object
    • java.lang.Enum
      • com.azure.core.http.policy.HttpLogDetailLevel

public enum HttpLogDetailLevel
extends Enum<HttpLogDetailLevel>

The HttpLogDetailLevel class is an enumeration of the levels of detail to log on HTTP messages.

This class is useful when you need to control the amount of information that is logged during the execution of HTTP requests. It provides several levels of detail, ranging from no logging at all to logging of headers and body content.

Code sample:

In this example, an HttpLogOptions is created and the log level is set to HttpLogDetailLevel.BODY_AND_HEADERS. This means that the URL, HTTP method, headers, and body content of each request and response will be logged. The HttpLogOptions is then used to create an HttpLoggingPolicy, which can then be added to the pipeline.

HttpLogOptions logOptions = new HttpLogOptions();
 logOptions.setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS);
 HttpLoggingPolicy loggingPolicy = new HttpLoggingPolicy(logOptions);

Fields

BASIC

Logs only URLs, HTTP methods, and time to finish the request.

BODY

Logs everything in BASIC, plus all the request and response body.

BODY_AND_HEADERS

Logs everything in HEADERS and BODY.

HEADERS

Logs everything in BASIC, plus all the request and response headers.

NONE

Logging is turned off.

Methods inherited from java.lang.Enum

Methods inherited from java.lang.Object

Methods

shouldLogBody()

public boolean shouldLogBody()

Whether a body should be logged.

Returns

boolean
Whether a body should be logged.

shouldLogHeaders()

public boolean shouldLogHeaders()

Whether headers should be logged.

Returns

boolean
Whether headers should be logged.

shouldLogUrl()

public boolean shouldLogUrl()

Whether a URL should be logged.

Returns

boolean
Whether a URL should be logged.

valueOf(String name)

public static HttpLogDetailLevel valueOf(String name)

Parameters

name
String

Returns

values()

public static HttpLogDetailLevel[] values()

Returns

Applies to