Switch branches/tags
Find file History


Logging Interceptor

An OkHttp interceptor which logs HTTP request and response data.

HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
OkHttpClient client = new OkHttpClient.Builder()

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.

HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new Logger() {
  @Override public void log(String message) {

Warning: The logs generated by this interceptor when using the HEADERS or BODY levels has 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 a non-production environment.


Get via Maven:

  <version>(insert latest version)</version>

or via Gradle

implementation 'com.squareup.okhttp3:logging-interceptor:(insert latest version)'