Detailed debug logs with Volley
Asked Answered
A

5

20

In Restkit on iOS there is a verbose debug option. RKLogConfigureByName("*", RKLogLevelTrace);. Does anyone know if there is an equivalent for Volley. Basically I am going straight to the ErrorListener but I get no additional info in LogCat. Both:

VolleyLog.e("Error: ", error.toString());

And:

VolleyLog.e("Error: ", error.getMessage());

Prints:

2.onErrorResponse: Error: 
Adamis answered 20/3, 2014 at 17:1 Comment(0)
U
33

If you want verbose Log from the volley library, you have to use adb

adb -s 42f63b0de7318fe1 shell setprop log.tag.Volley VERBOSE

where "42f63b0de7318fe1" is your device id which you will get by

adb devices

If you want to persist this setting use

adb -s 42f63b0de7318fe1 shell setprop persist.log.tag.Volley VERBOSE

If you have only 1 device you can omit the -s argument

see also How to set ADT system property in eclipse so it always runs

Kill and restart your app to apply the setting.

Unabridged answered 14/5, 2014 at 12:12 Comment(4)
Thanks. I gave up on Volley months ago and when with loopj's library.Adamis
Np, tought I just leave it here for the next to come :)Unabridged
You don't need to pass -s if you only have one device (emulator) runningJoelynn
The persist option did not work at all! So you're stuck with doing this at every debug session, until switching to Retrofit anyway :)Gavrielle
D
29

If you like Volley to output debug messages, you can simply set

VolleyLog.DEBUG = true;

then you will see all verbose log of Volley in out adb logcat output.

Dov answered 29/9, 2016 at 15:33 Comment(1)
This is more helpful than @for3st 's answer as you don't need to run the shell command every time on a different device. Thanks.Shaeffer
F
5

Use

VolleyLog.v("TAG", "Message"); 

for verbose debug option.

And to get other details you will have to try various options available with error object. Do CTRL + SPACE and go on a trial and error tour. :)

For example,

error.networkResponse.statusCode

will give the error code like 404 for page not found.

And, we can also use various Error Classes provided by Volley to check the type of error using

 if(error instanceOf TimeoutError ){
    // you got timed out  
 }

More details here. Have fun and Welcome to Android :)

Firsthand answered 20/3, 2014 at 17:15 Comment(1)
Many thanks. I get a NoConnectionError on the emulator on my mac. The investigation continues!! :)Adamis
L
2

What works for me as of Jan 2015 is

adb -s 0650ac52006b62db shell setprop Volley VERBOSE

"0650ac52006b62db" is the device id that you get with

adb devices

"Volley" is the name of the TAG that Volley has.

Legault answered 20/1, 2015 at 23:48 Comment(0)
J
0

I found that Volley logging is very limited. I needed to trace entire request/response information, not just request url.

I ended up with Android Studio Profiler (Network).

Good article that briefly describes how to enable it and what it shows https://proandroiddev.com/various-methods-to-debug-http-traffic-in-the-android-application-8685b9183418

Juncaceous answered 19/12, 2019 at 12:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.