С Retrofit вы должны использовать HttpLoggingInterceptor
Добавить зависимость в ваш файл build.gradle
, как показано ниже
implementation("com.squareup.okhttp3:logging-interceptor:4.4.0")
И затем установить HttpLoggingInterceptor для объекта Retrofit, как показано ниже
private val retrofit = Retrofit.Builder()
.baseUrl("https://devbytes.udacity.com/")
.addConverterFactory(MoshiConverterFactory.create(moshi))
.addCallAdapterFactory(CoroutineCallAdapterFactory())
.client(okHttpClient)
.build()
private val okHttpClient = OkHttpClient.Builder().addInterceptor(
HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
}
).build()
В случае предупреждения об устаревании просто измените setLevel
на:
level = HttpLoggingInterceptor.Level.BODY
Приведенное выше решение дает вам сообщения logcat, очень похожие на старые, установленные
level = RestAdapter.LogLevel.FULL