命令行抓log
adb logcat 抓取手机等设备的log 常用命令如下:
//如何显示 log 时间 (使用什么参数)
adb logcat -v time
//如何清除 log 缓存
adb logcat -c
//如何抓 event log
logcat -b events
其它的通过 adb logcat -help 查看
adb logcat 命令格式说明 : adb logcat [选项] [过滤项]
输出包含指定内容的log
adb logcat -s WiFiDirectBroadcastReceiver
adb logcat | grep Wifi
代码中动态Log开关
public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
adb shell setprop log.tag.<TAG> D
adb shell stop
adb shell start