square / retrofit

A type-safe HTTP client for Android and the JVM
https://square.github.io/retrofit/
Apache License 2.0
43.01k stars 7.3k forks source link

Logging in retrofit #1219

Closed dmitrikudrenko closed 8 years ago

dmitrikudrenko commented 8 years ago

I use retrofit-1.9.0, and I'd like to log my requests with responses. For it, I create own OkHttpClient and add my Interceptor:

public class LoggingInterceptor implements Interceptor {
        @Override
        public com.squareup.okhttp.Response intercept(Chain chain) throws IOException {
            //some work for logging
            return chain.proceed(chain.request());
        }
    }

But after that, there are no logs in logcat by retrofit. I'd like to receive that logs. How can I solve my problem?

dmitrikudrenko commented 8 years ago

Ok, in RestAdapter.Builder I added

.setLog(new RestAdapter.Log() {
     @Override
      public void log(String message) {
          Log.i("retrofit", message);
      }
})             

and I receive full logs in logcat