繁体   English   中英

日志方法之间的区别

[英]Difference between log methods

我是 android 的新手,我使用以下命令打印 log-cat:

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

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

Log.v() 
Log.d()

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

打印 log-cat 的最佳方法是什么?打印 lagcat 的方法是什么?它们之间的主要区别是什么?

常用的Log方法有五种:

Log.v ()冗长

Log.d ()调试

Log.i ()信息

Log.w ()警告

Log.e ()错误

1: Log.v - 调试颜色为黑色,任何消息都会是output,其中v代表verbose冗长的意思,一般是Log.v("","");

2: Log.d - output颜色为蓝色,只有output debug 调试的意思,但是他会通过DDMS Logcat label 的output 上层filter up 到select。

3: Log.i - output颜色为绿色,一般提示,新闻信息,它没有output Log.v Log.d的信息,但是会显示i,w,e的信息

4: Log.w -橙色的意思,可以看成是一个warning 这个warning,一般我们需要优化Android的代码,将output放在Log.e之后。

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

想要查询更多的信息:

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

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

想要查询更多的信息:

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

严重程度不同;

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

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.

暂无
暂无

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

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