Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display long messages in logcat

Tags:

android

logcat

I am trying to display long message on logcat. If the length of message is more than 1000 characters, it gets broken.

What is the mechanism to show all characters of long message in logcat?

like image 229
Vasu Avatar asked Sep 30 '11 04:09

Vasu


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 show messages on Android?

Display a message There are two steps to displaying a message. First, you create a Snackbar object with the message text. Then, you call that object's show() method to display the message to the user.

Which Android API class will allow you to output messages to Logcat?

util. Log is the class that has the methods you want, i.e. Log. i(), Log.

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.


1 Answers

If logcat is capping the length at 1000 then you can split the string you want to log with String.subString() and log it in pieces. For example:

int maxLogSize = 1000; for(int i = 0; i <= veryLongString.length() / maxLogSize; i++) {     int start = i * maxLogSize;     int end = (i+1) * maxLogSize;     end = end > veryLongString.length() ? veryLongString.length() : end;     Log.v(TAG, veryLongString.substring(start, end)); } 
like image 174
spatulamania Avatar answered Sep 28 '22 10:09

spatulamania