我是android的新手,我使用以下方式打印log-cat:
Log.w("Tag", "String text");
并记录文本打印,但在搜索了一段时间后,我找到了一些打印logcat的方法,如:
Log.v()
Log.d()
现在我对这些方法感到困惑。
打印log-cat的最佳方法是什么?打印lagcat的方法怎么样,它们之间的主要区别是什么?
答案 0 :(得分:11)
常用的Log
方法有五种:
Log.v ()
VERBOSE
Log.d ()
DEBUG
Log.i ()
信息
Log.w ()
警告
Log.e ()
错误
1: Log.v
- 调试 颜色黑色 ,并输出任何消息,其中v代表详细的详细均值,通常是Log.v("","");
2: Log.d
- 输出 颜色为蓝色 ,唯一的输出调试调试含义,但他会输出上层过滤DDMS Logcat标签进行选择。
3: Log.i
- 输出 颜色为绿色 ,一般提示,新闻信息,它不输出日志。 v Log.d信息,但会显示i,w和e的信息
4: Log.w
- 意味着 橙色 ,可以看作警告警告,一般我们需要优化Android代码,并将在Log.e。
5: Log.e
- 红色 ,您可以在此处看到错误错误,仅显示红色错误消息,这些错误我们需要仔细分析。
了解更多信息:
http://developer.android.com/guide/developing/debugging/debugging-log.html
答案 1 :(得分:5)
各种单字母方法表示日志消息的严重性。随后,您可以根据标记和严重性过滤日志消息,并防止较低严重性的消息显示在已发布的应用程序中(例如)。
了解更多信息:
http://developer.android.com/guide/developing/debugging/debugging-log.html
答案 2 :(得分:1)
严重程度不同;
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.
答案 3 :(得分:0)
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.