簡體   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