Android - 没有调试日志的 adb logcat
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11009062/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android - adb logcat without debug logs
提问by Vinoth
I don't want to see debug logs from adb logcat
command. There are ton's of debug logs from my phone and i don't want to see them.
我不想从adb logcat
命令中看到调试日志。我的手机中有大量调试日志,我不想看到它们。
adb logcat --help
says " *:I "
will output only info logs but is there any option to filter all logs except debug.
adb logcat --help
说" *:I "
将只输出信息日志,但是否有任何选项可以过滤除调试之外的所有日志。
回答by brianestey
From the docs here, when you specify a log level filter, it will show all messages at that level and higher. The levels are specified as:
从此处的文档中,当您指定日志级别过滤器时,它将显示该级别及更高级别的所有消息。级别指定为:
The tag of a log message is a short string indicating the system component from which the message originates (for > example, "View" for the view system).
The priority is one of the following character values, ordered from lowest to highest priority:
- V: Verbose (lowest priority)
- D: Debug
- I: Info
- W: Warning
- E: Error
- F: Fatal
- S: Silent (highest priority, on which nothing is ever printed)
...
The following filter expression displays all log messages with priority level "warning" and higher, on all tags:
adb logcat *:W
日志消息的标签是一个短字符串,指示消息源自的系统组件(例如,视图系统的“视图”)。
优先级是以下字符值之一,按优先级从低到高的顺序排列:
- V:详细(最低优先级)
- D:调试
- 我:信息
- W:警告
- E:错误
- F:致命
- S:静音(最高优先级,不打印任何内容)
...
以下过滤器表达式显示所有标记上具有“警告”及更高优先级的所有日志消息:
adb logcat *:W
So with this in mind, passing the filter you mentioned *:I
will log everything but Verbose and Debug logs.
因此,考虑到这一点,通过您提到的过滤器*:I
将记录除详细和调试日志之外的所有内容。
Unless your intention is to show Verbose as well as the other log levels, I don't think you can do that because specifying Verbose includes anything above Verbose.
除非您的意图是显示 Verbose 以及其他日志级别,否则我认为您不能这样做,因为指定 Verbose 包括高于 Verbose 的任何内容。
If that is the case, it might be useful for you to filter on a specific tag instead of a specific log level, or some combination of both.
如果是这种情况,过滤特定标签而不是特定日志级别或两者的某种组合可能对您有用。
回答by Rajesh
adb logcat *:I
will display alllogs with priority INFO and higher.
adb logcat *:I
将显示优先级为 INFO 和更高的所有日志。
The priority is one of the following character values, ordered from lowest to highest priority:
- V — Verbose (lowest priority)
- D — Debug
- I — Info
- W — Warning
- E — Error
- F — Fatal
- S — Silent (highest priority, on which nothing is ever printed)
优先级是以下字符值之一,按优先级从低到高的顺序排列:
- V - 详细(最低优先级)
- D——调试
- 我——信息
- W - 警告
- E - 错误
- F——致命
- S - Silent(最高优先级,不打印任何内容)
The above information is available in Write and View Logs with Logcat
上述信息可在使用 Logcat 写入和查看日志中获得
回答by Iman Marashi
To enable logging on some Huaweidevices:
在部分华为设备上启用登录:
Dial *#*#2846579#*#*
Select 'ProjectMenu'
Select 'Background Setting'
Select 'Log Setting'
Select 'Log Switch'
Enable 'LOG on'
Select 'Log level setting'
Enable 'DEBUG'
Press the 'Back' key
Select 'Dump and Log'
Enable 'Open Dump and Log'
Press 'Back' key 5 times to return to home screen.
Reboot the phone.
拨打*#*#2846579#*#*
选择“项目菜单”
选择“背景设置”
选择“日志设置”
选择“日志切换”
启用“登录”
选择“日志级别设置”
启用“调试”
按“返回”键
选择“转储和日志”
启用“打开转储和日志”
按“返回”键 5 次返回主屏幕。
重启手机。
LogCat should now work.
LogCat 现在应该可以工作了。
回答by AbePralle
logcat
won't let you show Debug only but you can show Debug and higher (Debug, Info, Warning, Error, Fatal) with:
logcat
不会让您只显示 Debug,但您可以显示 Debug 及更高版本(调试、信息、警告、错误、致命):
adb logcat YourLogTag:D *:S
adb logcat YourLogTag:D *:S
The *:S
suppresses logs from other apps.
该*:S
抑制来自其他应用程序日志。
You can pipe the result through grep
to only show Debug:
您可以通过管道grep
传输结果以仅显示调试:
adb logcat YourLogTag:D *:S | grep "D YourLogTag"
adb logcat YourLogTag:D *:S | grep "D YourLogTag"
回答by Grant
If you're on zshlike on Catalina OSXinstead of bash you may need to perform the following commands:
如果您在Catalina OSX上使用zsh而不是 bash,您可能需要执行以下命令:
Use --- noglob adb logcat *:E
--- replace the Ewith whatever, below.
使用 --- noglob adb logcat *:E
--- 将E替换为下面的任何内容。
Alternatively you can also use --- adb logcat '*:E'
--- (quotes around)
或者,您也可以使用 --- adb logcat '*:E'
--- (周围的引号)
V: Verbose
D: Debug
I: Info
W: Warning
E: Error
F: Fatal
S: Silent
The reason being that Zsh interprets the wildcard as you wanting to expand files ending in that letter without the quotes wrapping around or the noglob prefix.
原因是 Zsh 将通配符解释为您想要扩展以该字母结尾的文件,而没有引号环绕或 noglob 前缀。
回答by Chrishan
You can create a filter for a specific application using its package name.
您可以使用其包名称为特定应用程序创建过滤器。