Disable Volley logs in Android application
Asked Answered
A

3

7

The problem

I'm developing a SDK with using the Volley library for http(s) calls.

I'm able to hide my application logs using a customize Log class wrapper, and I would like to disable every log level printing of Volley, because it might expose sensitive information sent by HTTPS.

I know you can use proguard to disable logging of application, but I also want to be able to toggle logging on and off from the server side for debugging specific scenarios.

What have I tried

I took a look at the source, and it seems that the DEBUG flag in the VolleyLog class only changes the log level, but keeps ERROR calls in the log, so it isn't a solution for me.

Is it possible to hide all Volley logs ?

Aldershot answered 23/7, 2015 at 9:5 Comment(2)
Have you found a solution? I'm having a same issue and I can't find solution..Heeley
I'm also curious if you found a solution to this issue? I used ProGuard, but it did not work for the Volley error logs. linkHugohugon
A
6

I had same issue and finally after some google search i found the solution that is worked for me

    VolleyLog.DEBUG = false;

if you set DEBUG attribute to false you Volley Log is disabled

Ashkhabad answered 2/8, 2015 at 6:44 Comment(5)
Do we need to set this statement in each class or only in the starting activity?Salvadorsalvadore
Its better to add this line of code in Application class.Camembert
Volley still shows Log.e messages even when VolleyLog.DEBUG == falseEthyne
Where I add that ?Clearcole
hi , anywhere in your application ,but it is better before where you are initiate volley instanceAshkhabad
T
0

Source: https://github.com/google/volley/issues/125 It worked for me.

You can do this with Proguard, which is what I'd recommend as it's more efficient than flagging it off at runtime anyway. Something like:

-assumenosideeffects class com.android.volley.VolleyLog {
    public static void v(...);
    public static void d(...);
    public static void i(...);
    public static void w(...);
    public static void v(...);
}
Tiro answered 30/1, 2018 at 9:45 Comment(0)
H
0

I had no luck with VolleyLog.DEBUG = false; instead, this worked for me:

-assumenosideeffects class com.android.volley.VolleyLog {
    public static void v(...);
    public static void d(...);
    public static void e(...);
    public static void wtf(...);
}
Ho answered 19/2, 2021 at 17:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.