【问题标题】:Difference between log methods日志方法之间的区别
【发布时间】:2012-04-04 06:28:11
【问题描述】:

我是 android 新手,我使用以下方法打印 log-cat:

Log.w("Tag", "String text");

并记录文本打印,但在搜索了一段时间后,我找到了更多打印 logcat 的方法,例如:

Log.v() 
Log.d()

现在我对这些方法感到困惑。

print log-cat 的最佳方法是什么,print lagcat 的方法如何,它们之间的主要区别是什么?

【问题讨论】:

标签: java android


【解决方案1】:

常用的Log方法有五种:

Log.v () 详细

Log.d () 调试

Log.i ()信息

Log.w () 警告

Log.e ()错误

1: Log.v - 调试 color black ,任何消息都会输出,其中 v 代表verbose verbose mean,通常是 Log.v ("", "");

2: Log.d - 输出 color is blue ,唯一输出debug调试意思,但他会输出上层过滤器向上通过 DDMS Logcat 标签来选择。

3: Log.i - 输出color is green,一般提示,新闻信息,不输出Log.v Log .d信息,但会显示i、w、e的信息

4: Log.w - 意思是 orange ,可以看作是一个warning 的警告,一般我们需要优化Android代码,会在Log.e之后输出。

5: Log.e - 是红色 ,你可以想到error error 这里只是为了显示红色的错误信息,这些错误我们需要仔细分析。

更多信息:

http://developer.android.com/guide/developing/debugging/debugging-log.html

【讨论】:

【解决方案2】:

各种单字母方法表示日志消息的严重性。随后,您可以根据标签和严重性过滤日志消息,并防止在您发布的应用程序中显示较低严重性的消息(例如)。

更多信息:

http://developer.android.com/guide/developing/debugging/debugging-log.html

【讨论】:

    【解决方案3】:

    严重程度不同;

    Log.e() will simply log an error to the log with priority ERROR.
    

    一般情况下,使用Log.v() Log.d() Log.i() Log.w() and Log.e() 方法。

    详细程度从少到多的顺序是ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.

    【讨论】:

      【解决方案4】:
      int ASSERT Priority constant for the println method.
      int DEBUG Priority constant for the println method; use Log.d.
      int ERROR Priority constant for the println method; use Log.e.
      int INFO Priority constant for the println method; use Log.i.
      int VERBOSE Priority constant for the println method; use Log.v.
      int WARN Priority constant for the println method; use Log.w.
      

      【讨论】:

      • 介意补充几句解释吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-06
      • 1970-01-01
      • 1970-01-01
      • 2020-08-14
      • 1970-01-01
      • 2017-07-30
      • 1970-01-01
      相关资源
      最近更新 更多