Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable all VolleyLogs #125

Closed
ChristopherPrintuJoseph opened this issue Dec 13, 2017 · 17 comments
Closed

Disable all VolleyLogs #125

ChristopherPrintuJoseph opened this issue Dec 13, 2017 · 17 comments

Comments

@ChristopherPrintuJoseph

Hiding all VolleyLogs by setting VolleyLog.DEBUG to false is not working for all logs. How can we Disable all Logs(Log.e, Log.d etc) from volley. It seems like only the log.v can handle with the VolleyLog.DEBUG key.

@jpd236
Copy link
Collaborator

jpd236 commented Dec 13, 2017

Is there a particular reason you want to do this, or log entry you find spammy? The hope is that our default logging is helpful to users, and I'd rather adjust things that aren't helpful than provide a hook that just turns it all off.

But anyway, 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 e(...);
}

Please let me know if you are concerned about a particular log message being spammy or if the proguard solution isn't reasonable and we can discuss further.

@udeyogesh03
Copy link

Yes getting same issue and it print warning in logcat with URL, So for security purpose we want to disable that warning "A connection to https://abc.xyz.com/ was leaked. Did you forget to close a response body?"

is there any other way to disable above warning other than proguard or is there any alternate solution to disable above warning??

@jpd236
Copy link
Collaborator

jpd236 commented Jan 8, 2018

That error message does not come from Volley. From a quick search it appears to come from OkHttp.

@udeyogesh03
Copy link

We have not used OkHttp for network communication, I am using only Volley so is Volley internally used OkHttp? In over all project don't have the OkHttp reference.

@jpd236
Copy link
Collaborator

jpd236 commented Jan 9, 2018

Ah, perhaps it's coming from the Android platform then? Newer platform versions bundle a copy of OkHttp and use it for HttpUrlConnection under the covers. It might help if you share the log tag where that message is logged (i.e. the full line output under "adb logcat").

Anyway, based on the message I suspect what you're seeing is the same issue as #138, just with a different error, and it should be fixed once that is fixed.

@jpd236
Copy link
Collaborator

jpd236 commented May 3, 2018

Closing this out as a fix for #138 is out for review, and there's no other evidence of other log messages of concern here.

@jpd236 jpd236 closed this as completed May 3, 2018
@basmasrour
Copy link

error logs still appear when applying this
-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 e(...);
}

what should I do to disable all logs in the release version?

@basmasrour
Copy link

Is there a particular reason you want to do this, or log entry you find spammy? The hope is that our default logging is helpful to users, and I'd rather adjust things that aren't helpful than provide a hook that just turns it all off.

But anyway, 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(...);
}

Please let me know if you are concerned about a particular log message being spammy or if the proguard solution isn't reasonable and we can discuss further.
@jpd236
please advise it's not working, want to disable logs for the release version
Thanks.

@daedaesplayground1991
Copy link

daedaesplayground1991 commented Apr 10, 2019 via email

@jpd236
Copy link
Collaborator

jpd236 commented Apr 10, 2019

@basmasrour Can you provide a sample app reproducing the issue? What specific log statements do you still see?

@daedaesplayground1991 https://developer.android.com/studio/build/shrink-code

@basmasrour
Copy link

2019-04-10 16:16:31.602 5881-6774/? E/Volley: [103739] BasicNetwork.performRequest: Unexpected response code 500 for my_request_url

Or
No cache entry for my_request_url ....
And so on..
My volley version is 1.1.0

@jpd236
Copy link
Collaborator

jpd236 commented Apr 10, 2019

That log statement is coming from a call to VolleyLog.e, so it should be covered:

VolleyLog.e("Unexpected response code %d for %s", statusCode, request.getUrl());

Note that there was a typo previously in my above comment; make sure that your proguard config has the e() method included in it. Otherwise, this is likely an issue with your build and whether proguard is being applied correctly. One thing I'll note is that "BasicNetwork.performRequest" isn't obfuscated, which it would be if you had proguard obfuscation enabled. I'm not sure exactly what proguard flags would otherwise be needed for assumenosideeffects to work as expected, but some level of optimization would need to be enabled. This is more a question for the Android tooling side of things than Volley itself.

@basmasrour
Copy link

basmasrour commented Apr 10, 2019

Yes you can see in the first comment I write that I have put the e() function

Thank you for your reply, is there a detailed sample let me know if I'm working right with proguard? That will help a lot ...

Thanks in advance

@jpd236
Copy link
Collaborator

jpd236 commented Apr 10, 2019

I would recommend a more general support forum for help getting Proguard working - it's not particularly specific to Volley. If you think there's something Volley is doing incorrectly or which would make applying Proguard easier, then please let us know.

@jishantmed
Copy link

Why you are not checking DEBUG tag in logSlowRequests, you should use DEBUG check in all logs in VolleyLog class.

@basmasrour
Copy link

DEBUG flag check is just for Log.v() in VolleyRequest 😥
Can't find ability to disable all volley logs 😬

@jishantmed
Copy link

That is really frustrating, I have to take all project as a module. They cannot even do a simple DEBUG check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants