博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android中调试之日志
阅读量:4110 次
发布时间:2019-05-25

本文共 1985 字,大约阅读时间需要 6 分钟。

      开始利用零碎时间做android开发了,android中android.util.Log到底怎么要用呢?跟Java中的日志有什么区别呢?首先看下Log的源码

public final class Log {    /**     * Priority constant for the println method; use Log.v.     */    public static final int VERBOSE = 2;    /**     * Priority constant for the println method; use Log.d.     */    public static final int DEBUG = 3;    /**     * Priority constant for the println method; use Log.i.     */    public static final int INFO = 4;    /**     * Priority constant for the println method; use Log.w.     */    public static final int WARN = 5;    /**     * Priority constant for the println method; use Log.e.     */    public static final int ERROR = 6;    /**     * Priority constant for the println method.     */    public static final int ASSERT = 7;....................................}

 发现他共有6种级别,数字大的代表级别高,在代码中可以通过直接写日志的方式在logcat中查看,

5个常用的为Log.v() ,Log.d() ,Log.i() ,Log.w() ,Log.e() 

同时在记录日志的时候注意Log中的一个方法,看源码

/**     * Checks to see whether or not a log for the specified tag is loggable at the specified level.     *     *  The default level of any tag is set to INFO. This means that any level above and including     *  INFO will be logged. Before you make any calls to a logging method you should check to see     *  if your tag should be logged. You can change the default level by setting a system property:     *      'setprop log.tag.<YOUR_LOG_TAG> <LEVEL>'     *  Where level is either VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT, or SUPPRESS. SUPPRESS will     *  turn off all logging for your tag. You can also create a local.prop file that with the     *  following in it:     *      'log.tag.<YOUR_LOG_TAG>=<LEVEL>'     *  and place that in /data/local.prop.     *     * @param tag The tag to check.     * @param level The level to check.     * @return Whether or not that this is allowed to be logged.     * @throws IllegalArgumentException is thrown if the tag.length() > 23.     */    public static native boolean isLoggable(String tag, int level);
 具体的使用看doc

 

转载地址:http://juqsi.baihongyu.com/

你可能感兴趣的文章
Vue动态生成el-checkbox点击无法选中的解决方法
查看>>
python __future__
查看>>
MySQL Tricks1
查看>>
python 变量作用域问题(经典坑)
查看>>
pytorch
查看>>
pytorch(二)
查看>>
pytorch(三)
查看>>
pytorch(四)
查看>>
pytorch(5)
查看>>
pytorch(6)
查看>>
ubuntu相关
查看>>
C++ 调用json
查看>>
nano中设置脚本开机自启动
查看>>
动态库调动态库
查看>>
Kubernetes集群搭建之CNI-Flanneld部署篇
查看>>
k8s web终端连接工具
查看>>
手绘VS码绘(一):静态图绘制(码绘使用P5.js)
查看>>
手绘VS码绘(二):动态图绘制(码绘使用Processing)
查看>>
基于P5.js的“绘画系统”
查看>>
《达芬奇的人生密码》观后感
查看>>