Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying More string on Logcat

Tags:

android

logcat

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.

like image 827
bro Avatar asked Jan 11 '11 09:01

bro


People also ask

What is verbose in Android 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.

How do I write a Logcat file?

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.

How do I view android logs?

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.


2 Answers

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); } 
like image 138
Karussell Avatar answered Oct 05 '22 14:10

Karussell


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.

like image 45
Swapnil Mhaske Avatar answered Oct 05 '22 14:10

Swapnil Mhaske