Android retrofit2 questions

Asked 1 years ago, Updated 1 years ago, 137 views

Is there a way to automatically log the parameters used while using retrofit2? I think I can do something about the interceptor, but it's not working well

android retrofit2

2022-09-22 13:54

1 Answers

You can leave a log using the code below.

OkHttpClient client = new OkHttpClient.Builder()
            .addNetworkInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
            .build();

        Retrofit retrofit = new Retrofit.Builder()
            .client(client)
            .baseUrl(baseUrl)
            .build();

You can set the log level to suit your taste with BASIC, HEADERS, and BODY, so set it to the level you need.


2022-09-22 13:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.