Android 代码实现logcat输出到文件
来源:互联网 发布:2016中国软件城市排名 编辑:程序博客网 时间:2024/04/27 15:05
Android 的logcat支持直接输出到文件。
关键代码:
Runtime.getRuntime().exec("logcat -f "+ filePath);
我个人习惯是写在application的 oncreate()中。
logcat还支持很多其他参数,具体可以参见官方文档。
http://developer.android.com/tools/debugging/debugging-log.html#startingLogcat
这个方法不需要权限,但是对于其他应用的log,是打不出来的。
这是官方说明:
The change is that third party applications can no longer get the read logs permission, however every app can read the logs containing only the lines they have written, without needing any permission.
Keep in mind that access to the logs has never been part of the SDK, and is still not part of the SDK. If you are relying on it then, even after this change, you run the risk of breaking in the future. (And that is partly why this got lost for documentation, it is not part of the SDK, so there isn't really a place to document it, in fact documenting it would kind-of make it a part of the SDK which we don't want. :p)
- Android 代码实现logcat输出到文件
- Logcat输出到文件
- android下c代码如何输出到logcat?
- Android--保存logcat到文件
- logcat 实时输出日志到文件(logcat输出日志到文件)
- Android Studio NDK开发在C代码中将Log输出到logcat上面
- Android将logcat输出到屏幕、文件。TextView自动向下滚动、显示最后一行
- [Android]保存logcat到文件中
- Android中保存Logcat信息到文件
- android logcat日志保存到文件中
- android studio logcat写入到指定文件
- Android logcat信息记录到手机文件
- 如何将LogCat上的日志输出到文件?
- android替换fprintf使得打印可以输出到logcat中
- Qt打印调试信息输出到android logcat中
- Android本地程序的printf输出到logcat中
- android logcat 不输出
- android logcat输出
- 句子相似度
- 植物大战僵尸二:游戏界面的绘制
- main 标签
- 微信和百度地图都不支持iOS6了
- Spring中的DI(依赖注入)--给对象的属性赋值
- Android 代码实现logcat输出到文件
- 【.Net码农】 jquery访问ashx文件示例
- Unity技巧2
- DWZ实现排序
- 一场大雨引发的思考
- [网易笔试]Best Compression Algorithms
- javascript省市联动
- PAT(甲级)1012
- (date.getYear()+" "+date.getMonth() + " " + date.getDate()+" "+date.getDay()