Glide: How to disable logs for pictures that cannot be loaded (due to Error 404)?

Created on 20 Sep 2017  路  6Comments  路  Source: bumptech/glide


Glide Version: 4.1.1


Integration libraries: None


Device/Android Version: Genymotion Nexus 5X 7.1.1


Issue details / Repro steps / Use case background:
I am getting a long log when trying to load a picture that does not exists. I know the easiest fix is to add an updated/working url, but sometimes I won't be able to do that really quick and I don't want the logs to show unnecessary stuff, so I want to disable them.


Stack trace / LogCat:

09-19 19:33:28.176 11070-11070/jahirfiquitiva.apps.frames.sample W/Glide: 
    Load failed for https://raw.githubusercontent.com/username/Repository/master/ice.png with size [524x628]
    class com.bumptech.glide.load.engine.GlideException: Failed to load resource
        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE
          Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
            Cause (1 of 1): class com.bumptech.glide.load.HttpException: Not Found
09-19 19:33:28.176 11070-11070/jahirfiquitiva.apps.frames.sample I/Glide:
    Root cause (1 of 1)
        com.bumptech.glide.load.HttpException: Not Found
          at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:119)
          at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:54)
          at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:96)
          at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:147)
          at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:141)
          at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:60)
          at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:96)
          at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
          at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:286)
          at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:256)
          at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:226)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
          at java.lang.Thread.run(Thread.java:761)
          at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:347)
question

Most helpful comment

@sjudd

I only see Log.VERBOSE,聽Log.DEBUG,聽Log.INFO,Log.WARN, or聽Log.ERROR. Isn't there something like Log.NONE or something that could disable them completely?

All 6 comments

See http://bumptech.github.io/glide/doc/configuration.html#application-options for how to setup Glide. During setup you can use setLogLevel to reduce the verbosity of logs in Glide.

@sjudd

I only see Log.VERBOSE,聽Log.DEBUG,聽Log.INFO,Log.WARN, or聽Log.ERROR. Isn't there something like Log.NONE or something that could disable them completely?

@jahirfiquitiva Hello, I've reviewed some code in SingleRequest:

private void onLoadFailed(GlideException e, int maxLogLevel) {
    stateVerifier.throwIfRecycled();
    int logLevel = glideContext.getLogLevel();
    if (logLevel <= maxLogLevel) {
      Log.w(GLIDE_TAG, "Load failed for " + model + " with size [" + width + "x" + height + "]", e);
      if (logLevel <= Log.INFO) {
        e.logRootCauses(GLIDE_TAG);
      }
    }
   // other code omitted
}

In your case , if you only don't want to see those exceptions and causes, you can use setLevel() with Log.ERROR, just as @sjudd says.

However, if you are searching for more advanced needs(e.g only exclude 404, or HttpException), maybe currently no solution except fork repo and custom your own Request chain.

@Muyangmin Great. Thank you

Please add code to remove the logs

Please add code to remove the logs

Insert YourAppGlideModule class into your app)

import android.content.Context;
import android.util.Log;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;

@GlideModule
public class YourAppGlideModule extends AppGlideModule {
    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        builder.setLogLevel(Log.ERROR);
    }
}
Was this page helpful?
0 / 5 - 0 ratings