varmashrivastava
varmashrivastava

Reputation: 442

RxJava2 with Retrofit2-unable to get logs using HttpLoggingInterceptor

I have integrated RxJava2 with Retrofit2 and I am unable to get logs for api calls using HttpLoggingInterceptor.

I am using below dependencies-

compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.2'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'

and using below code

public class RxJavaRetofit {
    private  ApiMethods api;
    public RxJavaRetofit() {
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder()
                .addInterceptor(interceptor)
                .build();
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(AppUrls.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .client(client)
                .build();

          api = retrofit.create(ApiMethods.class);

  }

   public void getSocialFeed(Context context, SocialRequest socialRequest, final mevorun.mevolife.com.mevorun.listeners.onSocialServiceResponseHandler onServiceResponseHandler) {
       Utils.showDialog(context);
       api.getSocialData(socialRequest).subscribeOn(Schedulers.io())
               .observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<Social>() {
           @Override
           public void onSubscribe(Disposable d) {


           }

           @Override
           public void onNext(Social value) {
               try {
                   onServiceResponseHandler.onServerResponse(value.getResponse(),"Feed");
                   Utils.hideDialog();
               } catch (Exception e) {
                   e.printStackTrace();
               }
           }

           @Override
           public void onError(Throwable e) {


           }

           @Override
           public void onComplete() {

               Utils.hideDialog();

           }


       });
   }

In my Logcat I have selected Debug and searching HttpLoggingInterceptor but there is no log for that keyword.I tried in Verbose also but its not showing logs for api call.How can i get logs for my api call?

Upvotes: 1

Views: 219

Answers (1)

Fred
Fred

Reputation: 17085

This almost a comment not really an answer.

Everything looks ok with your code. The interceptor logs with the tag OkHttp. Searching for that should yield the logs you are looking for.

Upvotes: 1

Related Questions