如何过滤 ACRA 中的 logcat 输出?
Posted
技术标签:
【中文标题】如何过滤 ACRA 中的 logcat 输出?【英文标题】:How to filter logcat output in ACRA? 【发布时间】:2013-11-21 15:50:25 【问题描述】:我在我的应用程序中使用 ACRA 库。我的调试消息使用 Log 类中的方法写入 logcat。仅此消息包含 90% 的重要信息。 Logcat 输出包含在我的报告中。当我在模拟器上运行它时,它只包含我的消息和 printStackTrace() 方法的输出(如我所愿)。但是当我在真实设备(SGS4)上运行它时,我收到了太多不必要的消息。例如:
D/ProgressBar(10716): setProgressDrawable mProgressDrawable = null, d = android.graphics.drawable.LayerDrawable@4257df18needUpdate = false
D/ProgressBar(10716): setProgressDrawable drawableHeight = 0
D/ProgressBar(10716): setProgress = 0
D/ProgressBar(10716): setProgress = 0, fromUser = false
D/ProgressBar(10716): mProgress = 0mIndeterminate = false, mMin = 0, mMax = 100
D/ProgressBar(10716): updateDrawableBounds: bottom = 228
I/endeffect(10716): AbsListView.onMeasure(), getWidth()=750, getHeight()=1689, this=android.widget.ListView427234a0 VFED.VC. ......ID 0,0-750,1689 #7f070083 app:id/menu_list
I/endeffect(10716): AbsListView.onMeasure(), getWidth()=750, getHeight()=1689, this=android.widget.ListView427234a0 VFED.VC. ......ID 0,0-750,1689 #7f070083 app:id/menu_list
D/AbsListView(10716): unregisterIRListener() is called
D/AbsListView(10716): unregisterIRListener() is called
D/AbsListView(10716): unregisterIRListener() is called
D/AbsListView(10716): unregisterIRListener() is called
D/AbsListView(10716): unregisterIRListener() is called
D/AbsListView(10716): Get MotionRecognitionManager
D/AbsListView(10716): Get MotionRecognitionManager
W/Resources(10716): Converting to string: TypedValuet=0x10/d=0x3c a=-1
W/Resources(10716): Converting to string: TypedValuet=0x10/d=0x3c a=-1
I/CustomFrequencyManager(10716): newFrequencyRequest - mFrequency = 800000, mTimeoutMs = -1, mPkgName = LIST_SCROLL_BOOSTER@5
I/CustomFrequencyManager(10716): Boost Request from package = LIST_SCROLL_BOOSTER@5 frequency : 800000type = 6
I/CustomFrequencyManager(10716): !! pkgName = LIST_SCROLL_BOOSTER@5
I/CustomFrequencyManager(10716): Request from package name pkgName = LIST_SCROLL_BOOSTER@5
I/CustomFrequencyManager(10716): mToken is Null....Creating New Binder!
I/CustomFrequencyManager(10716): CPUDVFSControlRequest : doFrequencyRequest:: = 800000 Timeout : -1
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
E/SpannableStringBuilder(10716): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
Logcat 被此消息阻塞了大约 90%。但我不需要在此消息中。如何正确过滤?
现在我正在使用这个:
logcatArguments = "-t", "300", "ru.bartwell.myapp:V"
我也知道我可以只用我的消息编写自己的日志,然后将其包含在 ACRA 报告中。但是,如此频繁地写入文件是否正确?恐怕会对 SD 卡产生不利影响。
【问题讨论】:
【参考方案1】:你可以参考这个链接:
https://github.com/ACRA/acra/wiki/AdvancedUsage
For example, if you prefer using:
adb logcat -t 100 -v long ActivityManager:I MyApp:D :S 然后将此添加到您的 @ReportsCrashes 配置中: logcatArguments = "-t", "100", "-v", "long", "ActivityManager:I", "MyApp:D", ":S"
尝试提供更具体的 logcatArguments 命令。
经常写入 sdcard 不是正确的选择。
【讨论】:
【参考方案2】:我需要它:
logcatArguments = "-t", "300", "MyAppTag:V", "System.err:V", "AndroidRuntime:V", "*:S"
【讨论】:
以上是关于如何过滤 ACRA 中的 logcat 输出?的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Android Studio 中过滤 logcat?