Mohit Suthar Mohit Suthar - 1 year ago 207
Android Question

Cant resolve setLevel on HttpLoggingInterceptor Retrofit2.0

I am using Retrofit and I want to log my response and other things, I am using this type but I am facing Cant resolve setLevel error

HttpLoggingInterceptor logging = new HttpLoggingInterceptor();

logging.setLevel(Level.BODY); // i am getting error on this

OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

httpClient.addInterceptor(logging); //this is also getting error

I am using this
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1' and Retrofit
compile 'com.squareup.retrofit2:converter-gson:2.1.0' dependency.

This is where i got error

Answer Source

Write your interceptor code inside the getClient() method like

public class RestClient {

    public getClient() {

        HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download