gpt4 book ai didi

android logger 自发地降低其冗长级别(不是 Eclipse)

转载 作者:行者123 更新时间:2023-11-29 01:42:14 25 4
gpt4 key购买 nike

接受的答案:

  • 这是一个已知错误 (url)
  • 这是一个功能(url)

我不知道这是错误还是 Android 的特性。

我有一个调用 Log.d() 的应用程序,我会定期在我的设备上启动 logcat,通常它充满消息 - 大约 300kb/分钟,但有时它只是停止显示我的和大多数其他消息。我不知道可能是什么原因。

重启后一切正常。

奇怪的是,我使用了 Log.d(),但是我的消息不在那里,但是日志中仍然包含一些其他罕见的 D 消息

public class AaaTest extends AndroidTestCase {
public void testA() throws Exception {
Log.wtf("foobar", "loggableE = " + Log.isLoggable("foobar", Log.ERROR));
Log.wtf("foobar", "loggableW = " + Log.isLoggable("foobar", Log.WARN));
Log.wtf("foobar", "loggableI = " + Log.isLoggable("foobar", Log.INFO));
Log.wtf("foobar", "loggableD = " + Log.isLoggable("foobar", Log.DEBUG));
Log.wtf("foobar", "loggableV = " + Log.isLoggable("foobar", Log.VERBOSE));
Log.e("foobar", "this is error");
Log.w("foobar", "this is warning");
Log.i("foobar", "this is info");
Log.d("foobar", "this is debug");
Log.v("foobar", "this is verbose");
Log.e("foobar", "this is error again");
Log.wtf("foobar", "this is wtf");
}
}

_

adb logcat -v threadtime "*:S" "foobar:V"
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
05-21 20:06:36.601 16052 16068 F foobar : loggableE = true
05-21 20:06:36.629 16052 16068 F foobar : loggableW = true
05-21 20:06:36.652 16052 16068 F foobar : loggableI = true
05-21 20:06:36.672 16052 16068 F foobar : loggableD = false
05-21 20:06:36.686 16052 16068 F foobar : loggableV = false
05-21 20:06:36.808 16052 16068 E foobar : this is error
05-21 20:06:36.808 16052 16068 E foobar : this is error again
05-21 20:06:36.809 16052 16068 F foobar : this is wtf

看起来 isLoggable() 完全不相关。

我的设备是 Zopo ZP300+ Android 4.0.4

最佳答案

Logcat 日志保存在 circular buffers 中,因此所有应用仅保留最后“N”(~256K)个字节。

如果您手机上的某些其他应用程序开始喷出日志并填满缓冲区,您可能会开始看到日志被丢弃。如果您过滤日志(按级别或 TAG),您可能看不到所有日志都用完了缓冲区。

您可以通过以下方式获取有关缓冲区大小和使用情况的统计信息

adb logcat -g

如果您将 logcat 输出通过管道传输到一个文件并 tail -f 该文件,您应该会看到大部分日志。

在 Mac/Linux 上,您可以在本地保存 logcat:

adb logcat -v long >> /tmp/logcat.txt &

然后检查它:

tail -f /tmp/logcat.txt
grep <some_regex> /tmp/logcat.txt

如果您发现某些应用程序正在生成大量日志,您可以考虑禁用或卸载该应用程序,看看是否有帮助。

其他一些需要研究的工具:

引用资料

关于android logger 自发地降低其冗长级别(不是 Eclipse),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23776242/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com