开始利用零碎时间做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

更多相关文章

  1. 【Android】Android(安卓)联系人数据库浅析之通话记录
  2. android 编译源码 错误解决
  3. android开发每日汇总【2011-12-6】
  4. android 仿QQ手机版
  5. Android(安卓)Camera源码函数结构
  6. android framework 图解分享
  7. android底层开发
  8. Mac 10.12 快速下载 Android(安卓)源码
  9. Android(安卓)2.2.2到Android(安卓)4.2.2源码下载地址

随机推荐

  1. Android:Java Native Interface入门
  2. android Dialog 各种Dialog 三个选项的、
  3. Android(安卓)GridView 横向滚动 一行显
  4. android百度地图:卫星地图普通地图交通地
  5. eclipse 打开SDK manager报错 A folder f
  6. Android(安卓)背景图片重复平铺 Backgrou
  7. 用户界面View之ProgressBar
  8. Android(安卓)极光推送简单使用
  9. Android(安卓)logcat
  10. Android(安卓)动态权限 第三方库总结