Android - 设置 logcat 消息的最大长度 [英] Android - Set max length of logcat messages

查看:38
本文介绍了Android - 设置 logcat 消息的最大长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,logcat 似乎会截断它认为太长"的任何日志消息.这会在 Eclipse 内部以及使用 adb -d logcat 在命令行上运行 logcat 时发生,并且会截断一些重要的调试消息.

By default, it seems that logcat will truncate any log message that it considers to be "too long". This happens both inside of Eclipse and when running logcat on the command line using adb -d logcat, and is truncating some important debugging messages.

有什么办法可以增加logcat支持的最大字符串长度,让它停止截断调试信息?官方文档 暗示可能没有,但也许 logcat 支持一些那里没有提到其他选项?

Is there any way to increase the maximum string length supported by logcat to get it to stop truncating the debug information? The official documentation implies that there may not be, but maybe logcat supports some additional options not mentioned there?

推荐答案

logcat 中有一个固定大小的缓冲区用于二进制日志 (/dev/log/events) 并且这个限制是 1024 字节.对于非二进制日志也有一个限制:

There is a fixed size buffer in logcat for binary logs (/dev/log/events) and this limit is 1024 bytes. For the non-binary logs there is also a limit:

#define LOGGER_ENTRY_MAX_LEN        (4*1024)
#define LOGGER_ENTRY_MAX_PAYLOAD (LOGGER_ENTRY_MAX_LEN - sizeof(struct logger_entry))

因此二进制和非二进制日志的实际消息大小都是 ~4076 字节.内核记录器接口强加了这个 LOGGER_ENTRY_MAX_PAYLOAD 限制.

So the real message size for both binary and non-binary logs is ~4076 bytes. The kernel logger interface imposes this LOGGER_ENTRY_MAX_PAYLOAD limit.

liblog 源(由 logcat 使用)也说:

The liblog sources (used by logcat) also say:

  • 该消息可能已被内核日志驱动程序截断.

我会向您推荐 nxlog 工具,它不使用 logcat 二进制文件,但由于对于内核中的限制,我怀疑它能否解决您的问题.尽管如此,这可能值得一试.(免责声明:我是作者.)

I would recommend you the nxlog tool which does not use the logcat binary, but due to the limitations in the kernel I doubt that it will solve your problem. Nevertheless, it might be worth a try. (disclaimer: I'm the author.)

这篇关于Android - 设置 logcat 消息的最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆