手机重启后能否获取logcat日志?

发布于 2024-09-13 21:54:26 字数 428 浏览 6 评论 0原文

我正在测试一个带有长时间运行服务的 Android 应用程序。我正在使用 Eclipse,并将 USB 线连接到我旁边的电话。由于它是一项长期持续的服务,因此我在它运行时做了一些其他工作,并每隔一段时间检查一次 logcat 日志,以确保一切按预期进行。

几分钟前,我注意到手机重新启动。我认为它之前已经这样做过,因为它可以解释一些奇怪的应用程序行为。我很快切换到 Eclipse 看看发生了什么,发现 logcat 日志(看起来)在重新启动期间被清除了。因此,没有记录表明我的应用程序是否崩溃(并关闭了手机?!),或者是否存在其他问题导致手机和我的应用程序关闭。

无论如何我可以查出发生了什么事吗?这是一款开发手机,所以我不知道它是否经常自行重新启动/崩溃,或者仅在我的应用程序运行时重新启动/崩溃。它是运行固件版本 2.1-update1 的 Motorola Droid。

感谢您的帮助。

I'm testing an android application with a long running service. I'm using Eclipse and have the usb cord hooked up with the phone sitting next to me. 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.

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. 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.

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

薄荷→糖丶微凉 2024-09-20 21:54:26

我不知道有什么方法可以做到这一点。但是,您可以使用 adb logcat -v time > 在 adb 中启动 logcat logcat.txt,然后再次运行您的应用程序。如果第二次崩溃,那么您可以在您的计算机上查看 logcat.txt 中的输出。

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. If it crashes a second time, then you can go look at the output in logcat.txt on your machine.

盗琴音 2024-09-20 21:54:26

您可以使用adb bugreport,它应该包含一些有关虚假重启的信息 - 例如,内核恐慌、最后的 logcat 条目等。

不过请注意:此工具会输出大量信息,因此您必须深入挖掘才能找到您需要的东西。

You can use adb bugreport, which should contain some information regarding a spurious reboot - for example, a kernel panic, last logcat entries etc.

Be warned, though: this tool outputs immense amounts of information, so you'll have to dig deep to find what you need.

清旖 2024-09-20 21:54:26

我认为在主要的 Android 更新之一期间,崩溃日志已从 /proc/last_kmsg 移动到 /sys/fs/pstore/console-ramoops-0

I think that during one of major android update, crash logs are moved from /proc/last_kmsg to /sys/fs/pstore/console-ramoops-0

星光不落少年眉 2024-09-20 21:54:26

在较新的 Android 版本上,您可以尝试以下命令

adb logcat -b all -L

这应该输出“/sys/fs/pstore/console-ramoops-0”的内容。

注意:如果您的操作系统仍使用 /proc/last_kmsg 作为其上次重新启动日志,则此命令不起作用。

On newer android versions you can try the following command

adb logcat -b all -L

This should output the contents of '/sys/fs/pstore/console-ramoops-0'.

Note: This command does NOT work if your OS still uses /proc/last_kmsg for its last reboot logs.

冬天的雪花 2024-09-20 21:54:26

我也遇到过这个问题。应该可以编写一个应用程序,将 logcat 输出连续保存到 SD 卡上的文件中。市场上有一些应用程序可以显示 logcat 输出,因此我知道可以从应用程序内访问它。

@djv,我无法在手机上的 root 或 /data 中找到 /log 目录。

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. There are apps on the market that display the logcat output, so I know it is accessible from within an application.

@djv, I wasn't able to find a /log directory in either root or /data on my phone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文