12

Consider the code below:

Glide.with(<your_context>)
    .load(<remote_file_url, local_file_path>)
    .into(<imageview>);

Above Glide code is written in lots of file. Simply I want to log my remote_file_url or local_file_path in logcat. But I don't want to change the code in every file.

Is Glide allowing logging? If it allows, then I need a simple central way to turn on glide logging.

For Reference: I want the way like Retrofit + okhttp allow. In OkHttp, I just have to add interceptor at one location and it will log information about each webservice call without writing any other additional code.

azizbekian
  • 60,783
  • 13
  • 169
  • 249
Moinkhan
  • 12,732
  • 5
  • 48
  • 65

1 Answers1

23

In Glide 4.0 RC that's possible via Glide configuration: you can configure Glide's logging level via GlideBuilder#setLogLevel(int).

Having MyGlideModule.java:


@GlideModule
public class MyGlideModule extends AppGlideModule {
  @Override
  public void applyOptions(Context context, GlideBuilder builder) {
    builder.setLogLevel(Log.VERBOSE);
  }
}

Then you'll be able to see following log in console:

enter image description here


For older versions (3.x), as mentioned in "Debugging workflow":

To view how and when Glide's internal engine finds the resources you asked for, you can enable logging:

adb shell setprop log.tag.Engine VERBOSE

adb shell setprop log.tag.EngineJob VERBOSE

adb shell setprop log.tag.DecodeJob VERBOSE

This will prompt with following output:

enter image description here

You can enable only Engine logging if you are not interested in other logs.

Community
  • 1
  • 1
azizbekian
  • 60,783
  • 13
  • 169
  • 249
  • thanks for answer. But it seems that `builder.setLogLevel(Log.VERBOSE);` is only available in glide v4 version while i am using 3.7.0. – Moinkhan Jun 20 '17 at 05:43
  • And in latest version i am not able to use `PlaceHolder` also. – Moinkhan Jun 20 '17 at 05:45
  • Nope, haven't got a chance yet. But would certainly consider moving to, regardless it's in "release candidate" stage or no. – azizbekian Jun 20 '17 at 07:18
  • Yep it's in RC version. In v4 there is no need to give meta data in manifest. When I add meta data it gives me exception `Expected instanceof GlideModule, but found:.`. And also there are annotation available from v4. So no need to add it in meta data. – Moinkhan Jun 20 '17 at 07:40
  • The original answer I gave was not tailor-made for v4, it's just that I knew that Glide may be configured from modules. I believe there must be a better approach with v4. – azizbekian Jun 20 '17 at 07:45
  • 1
    Can you implement v4 and update the answer then i will accept it, Currently `setLogLevel()` is in v4, while meta data is not supported in v4(i thought), So if i accept this answer it may misguide to audience, .. If you can't update it, then don't worry i will edit your answer and will accept it. BTW thanx for your effort. – Moinkhan Jun 20 '17 at 07:54
  • Is it possible to enable Engine logs in V4? `adb shell setprop log.tag.Engine VERBOSE` doesn't work – Torima Mar 09 '22 at 16:36