//如下新建了一个单元测试类。
public class MyLogTest extends AndroidTestCase {
private static final String tag="MyLogTest";
public void testOutLog()throws Throwable{
Log.v(tag, "verbose "); //详细信息。
Log.d(tag, "debug"); //调试信息
Log.i(tag, "information"); //信息
Log.w(tag, "warning"); //警告信息,这里提示的一般可以优化代码
Log.e(tag, "error"); //错误信息
System.out.println("information"); //information级别
System.err.println("information"); //warning 级别
//两种System输出,默认tag为System.out 因为标签默认且不可修改,
//所以不建议使用。
}
tag标签,用于在logcat中快速区分识别。可设置帅选器筛选。
tag因为会经常用到,最好设置为 private static final 属性 。
此外,LogCat视图是不支持显示中文的,显示乱码,因此,不一定代表程序出错了。