Can I get logcat logs after phone reboots?

2019-01-16 16:59发布

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.

3条回答
够拽才男人
2楼-- · 2019-01-16 17:27

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.

查看更多
小情绪 Triste *
3楼-- · 2019-01-16 17:28

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.

查看更多
该账号已被封号
4楼-- · 2019-01-16 17:38

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.

查看更多
登录 后发表回答