A previous version of Retrofit uses the RestAdapter and provides the ability to enable logs. Why is this feature removed in Retrofit 2.0 ?
To enable the log, I have to do this.
Retrofit retrofit = new Retrofit.Builder() .baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .build(); retrofit.client().interceptors().add(new LoggingInterceptor()); class LoggingInterceptor implements Interceptor { @Override public Response intercept(Interceptor.Chain chain) throws IOException { Request request = chain.request(); long t1 = System.nanoTime(); Logger.d(String.format("Sending request %s on %s%n%s", request.url(), chain.connection(), request.headers())); Response response = chain.proceed(request); long t2 = System.nanoTime(); Logger.d(String.format("Received response for %s in %.1fms%n%s", response.request().url(), (t2 - t1) / 1e6d, response.headers()));
Is this the only solution for this? The previous position was very convenient ...
android rest retrofit
sreekumar Oct. 15 '15 at 6:30 2015-10-15 06:30
source share