android.util.Log 日志查看
先看一下 android 的 Log API:
java.lang.Object ↳ android.util.Log
Class Overview
API for sending log output.
Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods.
The order in terms of verbosity, from least to most is 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.
Public Methods static int d(String tag, String msg, Throwable tr) Send a DEBUG log message and log the exception. static int d(String tag, String msg) Send a DEBUG log message. static int e(String tag, String msg) Send an ERROR log message. static int e(String tag, String msg, Throwable tr) Send a ERROR log message and log the exception. static String getStackTraceString(Throwable tr) Handy function to get a loggable stack trace from a Throwable static int i(String tag, String msg, Throwable tr) Send a INFO log message and log the exception. static int i(String tag, String msg) Send an INFO log message. static boolean isLoggable(String tag, int level) Checks to see whether or not a log for the specified tag is loggable at the specified level. static int println(int priority, String tag, String msg) Low-level logging call. static int v(String tag, String msg, Throwable tr) Send a VERBOSE log message and log the exception. static int v(String tag, String msg) Send a VERBOSE log message. static int w(String tag, String msg) Send a WARN log message. static int w(String tag, Throwable tr) static int w(String tag, String msg, Throwable tr) Send a WARN log message and log the exception.
这些调用定义都是static,大家都知道所有的类都继承object,OK,我们可以在直接调用这些方法; 但大家可能发现没有在控制台发现日志信息,但代码已执行,日志写哪去了? 这个就得问adb了,在sdk/tools/下执行adb logcat就可以了,还可以过滤信息,使用方式有很多,具体请大家查adb使用说明。
补充一下,在eclipse中也是可以查看log的,只是非默认的android控制台窗口,可以在show view/other/android选择logCat即可;