如何在ACRA中过滤logcat输出?

时间:2013-11-21 15:50:26

标签: android logcat

我在我的应用程序中使用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.ListView{427234a0 VFED.VC. ......ID 0,0-750,1689 #7f070083 app:id/menu_list}
I/endeffect(10716): AbsListView.onMeasure(), getWidth()=750, getHeight()=1689, this=android.widget.ListView{427234a0 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: TypedValue{t=0x10/d=0x3c a=-1}
W/Resources(10716): Converting to string: TypedValue{t=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卡产生负面影响。

2 个答案:

答案 0 :(得分: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命令。

经常写入SD卡不是正确的选择。

答案 1 :(得分:1)

我需要它:

logcatArguments = { "-t", "300", "MyAppTag:V", "System.err:V", "AndroidRuntime:V", "*:S" }