square / retrofit

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

Full logging with retrofit 2.0 #1414

Closed KadamMangesh closed 8 years ago

KadamMangesh commented 8 years ago

I cant see request data passed in retrofit 2.0 logging. I can see other header information but not the request data. Any idea how to get full logging ?

JakeWharton commented 8 years ago

You need to use OkHttp's Logging Interceptor: https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor#readme

KadamMangesh commented 8 years ago

I am following the same. But I could not see request data. All I can see is response data.

KadamMangesh commented 8 years ago

this was the problem with android studio. I tried logs in command prompt and its working now. Thanks.

zyallday commented 8 years ago

try this client.networkInterceptors().add(new LoggingInterceptor());

cesar-oyarzun-m commented 8 years ago

@JakeWharton I'm using the HttpLoggingInterceptor but I can't see the logs for my POST request

// Define the interceptor, add authentication headers
    Interceptor interceptor = new Interceptor() {
        @Override
        public Response intercept(Chain chain) throws IOException {
            Request newRequest = chain.request().newBuilder().addHeader(AUTHORIZATION, BEARER +tokenExp).build();
            return chain.proceed(newRequest);
        }
    };

    //Loggin Interceptor
    HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
    httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

    // Add the interceptor to OkHttpClient
    OkHttpClient client = new OkHttpClient();
    client.interceptors().add(httpLoggingInterceptor);
    client.interceptors().add(interceptor);