简体   繁体   English

我可以在手机重启后获取 logcat 日志吗?

[英]Can I get logcat logs after phone reboots?

I'm testing an android application with a long running service.我正在测试具有长期运行服务的 android 应用程序。 I'm using Eclipse and have the usb cord hooked up with the phone sitting next to me.我正在使用 Eclipse 并将 usb 线与坐在我旁边的电话相连。 Since it's a long ongoing service, I do some other work while it runs and check the logcat logs every once in a while to make sure everything is going as expected.由于这是一项长期持续的服务,我在它运行时做了一些其他工作,并每隔一段时间检查一次 logcat 日志,以确保一切都按预期进行。

A few minutes ago I noticed the phone rebooting.几分钟前,我注意到手机重新启动了。 I think it's done this before as it would explain some weird application behavior.我认为它之前已经这样做过,因为它可以解释一些奇怪的应用程序行为。 I quickly switched over to Eclipse to see what happened and found that the logcat log was (it seems) cleared during the reboot.我迅速切换到 Eclipse 看看发生了什么,发现 logcat 日志在重启过程中(似乎)被清除了。 So there's no log of whether my app crashed (and took down the phone?.) or if there was some other problem that took down the phone and my app.因此,没有关于我的应用程序是否崩溃(并关闭了手机?)或者是否存在其他问题导致手机和我的应用程序关闭的日志。

Is there anyway I can find out what happened?无论如何我可以找出发生了什么事吗? This is a development phone, so I don't know if it reboots/crashes often on its own, or only while my app is running.这是一款开发手机,所以我不知道它是经常自行重启/崩溃,还是仅在我的应用程序运行时重启/崩溃。 It's a Motorola Droid running Firmware version 2.1-update1.这是运行固件版本 2.1-update1 的摩托罗拉 Droid。

Thanks for your help.谢谢你的帮助。

I don't know of any way to do this. 我不知道有什么方法可以做到这一点。 However, you could start up logcat in adb with adb logcat -v time > logcat.txt and then run your app again. 但是,您可以使用adb logcat -v time > logcat.txtadb启动logcat,然后再次运行您的应用程序。 If it crashes a second time, then you can go look at the output in logcat.txt on your machine. 如果它再次崩溃,那么您可以查看logcat.txtlogcat.txt中的输出。

You can use adb bugreport , which should contain some information regarding a spurious reboot - for example, a kernel panic, last logcat entries etc. 您可以使用adb bugreport ,它应包含有关虚假重启的一些信息 - 例如,内核崩溃,最后一个logcat条目等。

Be warned, though: this tool outputs immense amounts of information, so you'll have to dig deep to find what you need. 但请注意:此工具会输出大量信息,因此您必须深入挖掘才能找到所需信息。

I have run into this problem as well. 我也遇到过这个问题。 It should be possible to write an app that continuously saves the logcat output to a file on the SD card. 应该可以编写一个应用程序,将logcat输出连续保存到SD卡上的文件中。 There are apps on the market that display the logcat output, so I know it is accessible from within an application. 市场上有一些显示logcat输出的应用程序,所以我知道它可以在应用程序中访问。

@djv, I wasn't able to find a /log directory in either root or /data on my phone. @djv,我无法在手机的root或/ data中找到/ log目录。

I think that during one of major android update, crash logs are moved from /proc/last_kmsg to /sys/fs/pstore/console-ramoops-0我认为在 android 的主要更新之一期间,崩溃日志从/proc/last_kmsg/sys/fs/pstore/console-ramoops-0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM