Android 设备的日志文件
使用 logcat 我可以在模拟器中查看我的应用程序生成的日志消息。我如何读取/检索相同的日志文件,但这次是从运行应用程序的设备读取/检索?该设备未连接到任何计算机,日志文件必须通过电子邮件发送。
using logcat I can see the log messages generated by my app in the emulator. How can I read/retrieve the same log file but this time from the device the app is running on ? The device is not attached to any computer and the log file has to be sent via email.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要从应用程序内读取日志,您需要拥有 android.permission.READ_LOGS 权限。
一旦你有了这个,你就可以启动一个进程来读取 logcat ,类似于
然后你可以从中创建一个缓冲读取器:
从这里你可以
String s = logcat.readLine();
来读取日志。To read the log from within your application you need to have the android.permission.READ_LOGS permission.
Once you have that, you could start up a process to read logcat with something like
Then you can create a buffered reader from it:
From here you can
String s = logcat.readLine();
to read the log.您可以在代码/应用程序中使用日志收集器项目。如果您想要现有的应用程序,请尝试日志收集器。
There is a log collector project that you can use from your code/application. If you want an already existing application, try Log Collector.
查看市场上的这款应用。它可以满足您的需求,并且是开源的!
Check out this app on the market. It does what you need and it is open source!