Home | History | Annotate | only in /external/okhttp/okhttp-logging-interceptor
Up to higher level directory
NameDateSize
pom.xml21-Aug-20181.2K
README.md21-Aug-20181.3K
src/21-Aug-2018

README.md

      1 Logging Interceptor
      2 ===================
      3 
      4 An [OkHttp interceptor][1] which logs HTTP request and response data.
      5 
      6 ```java
      7 OkHttpClient client = new OkHttpClient();
      8 HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
      9 logging.setLevel(Level.BASIC);
     10 client.interceptors().add(logging);
     11 ```
     12 
     13 You can change the log level at any time by calling `setLevel`.
     14 
     15 To log to a custom location, pass a `Logger` instance to the constructor.
     16 ```java
     17 HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new Logger() {
     18   @Override public void log(String message) {
     19     Timber.tag("OkHttp").d(message);
     20   }
     21 });
     22 ```
     23 
     24 **Warning**: The logs generated by this interceptor when using the `HEADERS` or `BODY` levels has
     25 the potential to leak sensitive information such as "Authorization" or "Cookie" headers and the
     26 contents of request and response bodies. This data should only be logged in a controlled way or in
     27 a non-production environment.
     28 
     29 
     30 Download
     31 --------
     32 
     33 Get via Maven:
     34 ```xml
     35 <dependency>
     36   <groupId>com.squareup.okhttp</groupId>
     37   <artifactId>logging-interceptor</artifactId>
     38   <version>(insert latest version)</version>
     39 </dependency>
     40 ```
     41 
     42 or via Gradle 
     43 ```groovy
     44 compile 'com.squareup.okhttp:logging-interceptor:(insert latest version)'
     45 ```
     46 
     47 
     48 
     49  [1]: https://github.com/square/okhttp/wiki/Interceptors
     50