I am currently working on an android App that uses 'JSON' as response from server. Usually I work on the JSON response. But now I have a problem with logcat, if the JSON response string is very long , more than x character (i don't know exactly how much is the max string that could be displayed by logcat), some of the JSON string is missing.
Although it still could give me the output, I need the information on the JSON string that is transmitted from the server.
Is there any possibility to display more string on logcat? Like increasing the buffer or any parameter that I could use to increase the maximum string length that could be displayed by logcat.
Verbose: Show all log messages (the default). Debug: Show debug log messages that are useful during development only, as well as the message levels lower in this list. Info: Show expected log messages for regular usage, as well as the message levels lower in this list.
adb logcat –d > filename.txt This command will extract the logcat information from the connected device and redirects the output to a file on the PC. The option –d will take care that the output will stop when all output is flushed.
Log messages can be viewed in a Logcat window in Android Studio, or you can use the command line tool to pull them. Several Android apps are also available in the Google Play store that allow easy access to these tools.
Ugly but it does the job:
public static void longInfo(String str) { if(str.length() > 4000) { Log.i(TAG, str.substring(0, 4000)); longInfo(str.substring(4000)); } else Log.i(TAG, str); }
if(xml.length() > 4000) { for(int i=0;i<xml.length();i+=4000){ if(i+4000<xml.length()) Log.i("rescounter"+i,xml.substring(i, i+4000)); else Log.i("rescounter"+i,xml.substring(i, xml.length())); } } else Log.i("resinfo",xml);
This is how I did it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With