mirror of
https://github.com/square/okhttp.git
synced 2025-08-08 23:42:08 +03:00
Document HttpLoggingInterceptor.redactHeader()
This commit is contained in:
@@ -11,7 +11,7 @@ OkHttpClient client = new OkHttpClient.Builder()
|
|||||||
.build();
|
.build();
|
||||||
```
|
```
|
||||||
|
|
||||||
You can change the log level at any time by calling `setLevel`.
|
You can change the log level at any time by calling `setLevel()`.
|
||||||
|
|
||||||
To log to a custom location, pass a `Logger` instance to the constructor.
|
To log to a custom location, pass a `Logger` instance to the constructor.
|
||||||
```java
|
```java
|
||||||
@@ -22,11 +22,16 @@ HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new Logger() {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
**Warning**: The logs generated by this interceptor when using the `HEADERS` or `BODY` levels has
|
**Warning**: The logs generated by this interceptor when using the `HEADERS` or `BODY` levels have
|
||||||
the potential to leak sensitive information such as "Authorization" or "Cookie" headers and the
|
the potential to leak sensitive information such as "Authorization" or "Cookie" headers and the
|
||||||
contents of request and response bodies. This data should only be logged in a controlled way or in
|
contents of request and response bodies. This data should only be logged in a controlled way or in
|
||||||
a non-production environment.
|
a non-production environment.
|
||||||
|
|
||||||
|
You can redact headers that may contain sensitive information by calling `redactHeader()`.
|
||||||
|
```java
|
||||||
|
logging.redactHeader("Authorization");
|
||||||
|
logging.redactHeader("Cookie");
|
||||||
|
```
|
||||||
|
|
||||||
Download
|
Download
|
||||||
--------
|
--------
|
||||||
|
Reference in New Issue
Block a user