简体   繁体   English

如何禁用ACRA的日志记录

[英]How to disable the logging of ACRA

I'm using ACRA for crash reporting in my app. 我在应用程序中使用ACRA进行崩溃报告。 (In brief, ACRA is a tool for sending crash reports to the developer.) (简而言之,ACRA是用于将崩溃报告发送给开发人员的工具。)

Even in release builds, I can see its logs in the device's logcat (for example when it sends a crash report, it sends many log lines with "ACRA" tag). 即使在发行版本中,我也可以在设备的logcat中看到其日志(例如,当它发送崩溃报告时,它会发送许多带有“ ACRA”标签的日志行)。

Is there a way to disable its logging? 有没有办法禁用其日志记录?

Based on the comments below, let me emphasize again: I'm asking to disable the logging of ACRA itself. 根据以下评论,让我再次强调:我要求禁用ACRA本身的日志记录。 The question has nothing to do with ACRA's crashing or with the system logcat during app crashes. 这个问题与ACRA崩溃或应用崩溃期间的系统logcat无关。

I think the best is to provide an example about what I mean: 我认为最好是提供一个有关我的意思的示例:

04-13 02:33:50.980: D/ACRA(4560): Using custom Report Fields
04-13 02:33:51.170: I/ACRA(4560): READ_LOGS not allowed. ACRA will not include LogCat and DropBox data.
04-13 02:33:51.170: D/ACRA(4560): Writing crash report file 1667311131000.stacktrace.
04-13 02:33:51.200: D/ACRA(4560): About to start ReportSenderWorker from #handleException
04-13 02:33:51.200: D/ACRA(4560): Waiting for Toast + worker...

To disable ACRA's logging, you might want to use this implementation of the ACRALog interface: 要禁用ACRA的日志记录,您可能要使用ACRALog接口的以下实现:

public class NoAcraLog implements ACRALog {

    @Override
    public int v(String tag, String msg) {
        return 0;
    }

    @Override
    public int v(String tag, String msg, Throwable tr) {
        return 0;
    }

    @Override
    public int d(String tag, String msg) {
        return 0;
    }

    @Override
    public int d(String tag, String msg, Throwable tr) {
        return 0;
    }

    @Override
    public int i(String tag, String msg) {
        return 0;
    }

    @Override
    public int i(String tag, String msg, Throwable tr) {
        return 0;
    }

    @Override
    public int w(String tag, String msg) {
        return 0;
    }

    @Override
    public int w(String tag, String msg, Throwable tr) {
        return 0;
    }

    @Override
    public int w(String tag, Throwable tr) {
        return 0;
    }

    @Override
    public int e(String tag, String msg) {
        return 0;
    }

    @Override
    public int e(String tag, String msg, Throwable tr) {
        return 0;
    }

    @Override
    public String getStackTraceString(Throwable tr) {
        return null;
    }
}

Provide an instance of this class to ACRA : ACRA提供此类的实例:

ACRA.setLog(new NoAcraLog());

This should disable all logging of ACRA since the abovementioned implementation would do nothing. 这将禁用ACRA的所有日志记录,因为上述实现将无济于事。 (FYI: normally ACRA uses AndroidLogDelegate which redirects log messages to the Log class.) (仅供参考:通常ACRA使用AndroidLogDelegate将日志消息重定向到Log类。)

关于“启用/禁用系统日志”的这一部分可能会有所帮助-https: //github.com/ACRA/acra/wiki/AdvancedUsage#enabledisable-system-logs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM