简体   繁体   中英

How to disable the logging of ACRA

I'm using ACRA for crash reporting in my app. (In brief, ACRA is a tool for sending crash reports to the developer.)

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).

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. The question has nothing to do with ACRA's crashing or with the system logcat during app crashes.

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:

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.setLog(new NoAcraLog());

This should disable all logging of ACRA since the abovementioned implementation would do nothing. (FYI: normally ACRA uses AndroidLogDelegate which redirects log messages to the Log class.)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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