如何显示长消息在logcat中消息、logcat

2023-09-14 23:02:49 作者:一个嗨皮的小逗包

我想在logcat中显示长消息。如果消息的长度超过1000个字符,它就会被折断。

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

什么机制来显示长信息的全部字符的logcat?

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

推荐答案

如果是的logcat封盖的长度1000,那么可以拆分要记录与String.subString(),并在片记录它的字符串。例如:

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));
}