【问题标题】:Is it possible to read the Slog in android monitor?是否可以在 android 监视器中读取 Slog?
【发布时间】:2017-11-05 12:25:10
【问题描述】:

在android源代码中我经常看到Slog.v(WindowManagerService.TAG, "First window added to " + this + ", creating SurfaceSession");这样的行我如何在android监视器下看到那些Slog? Slog和Log有什么区别?

【问题讨论】:

    标签: android android-log


    【解决方案1】:

    简答

    默认情况下,您会使用Slog 记录日志,但它们会“隐藏”在其他日志消息之间。为了只获取使用Slog 记录的那些,请使用以下命令:

    adb logcat -b system
    

    长答案

    我查看了Slog.java的来源:

    public static int v(String tag, String msg) {
        return Log.println_native(Log.LOG_ID_SYSTEM, Log.VERBOSE, tag, msg);
    }
    

    Log.java相比:

    public static int v(String tag, String msg) {
        return println_native(LOG_ID_MAIN, VERBOSE, tag, msg);
    }
    

    如您所见,区别仅在于LOG_ID 参数。

    然后我看了adb logcat -help

      ...
      -b <buffer>     Request alternate ring buffer, 'main', 'system', 'radio',
                      'events', 'crash' or 'all'. Multiple -b parameters are
                      allowed and results are interleaved. The default is
                      -b main -b system -b crash.
      ...
    

    我没有进一步检查 - -b 选项对应于不同的 LOG_ID 参数看起来很安全。

    【讨论】:

    • 感谢 vasiliy,如果我执行 adb logcat -b system 我会看到日志出现在 android 监视器中还是仅出现在 Windows 控制台中?
    • @lok​​i 我总是使用命令行。也许有办法在Android Studio中得到它,但我不知道如何......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多