7

I am developing an application and during my testing on a real device I have found that it will crash and cause the phone to reboot (worrying I know...)

Is there any way I retrieve the logcat from before the phone rebooted as the logcat seems to reset when the phone boots up.

Thanks in advance.

stealthcopter
  • 13,964
  • 13
  • 65
  • 83
  • 1
    This may be relevant to this question: http://stackoverflow.com/questions/3469016/can-i-get-logcat-logs-after-phone-reboots/3470112 – adamk Aug 12 '10 at 17:00
  • have a look at https://stackoverflow.com/a/10525021/529977 `/data/dontpanic` – childno͡.de Jun 14 '17 at 16:24

6 Answers6

3

Use http://code.google.com/p/acra/, which is a great lib to send crash reports to a google form incl. stack trace. I use it in my app and works nicely. Let me know if you have any difficulties implementing it. Read the http://code.google.com/p/acra/wiki/ACRAHowTo, it's easy to setup.

Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192
  • 1
    Surely the device would reboot before it would have a chance to upload the log to the internet? – Karu May 14 '16 at 22:11
  • This is a while ago when I posted the answer or used Acra, but it's quite possible that Acra stores the error log locally first before submitting it (when an internet connection is available). Such feature also makes sense when testing apps in flightmode. Possible that it's supported - if not, it could be added since it's open source. – Mathias Conradt May 14 '16 at 23:35
  • Here is the way to do it: implement own "sender" which writes to a local log file for example. https://github.com/ACRA/acra/wiki/Report-Destinations#implementing-your-own-sender – Mathias Conradt May 14 '16 at 23:45
2

Easiest way: Get aLogrec from Market for free. This app saves the logs to sdcard.

Tim Abell
  • 11,186
  • 8
  • 79
  • 110
fivef
  • 2,397
  • 21
  • 21
  • 1
    Yes, there are a few apps like this out there, also CatLog, LogViewer Lite, and others. It's good for manual log checking; if the developer wants to get crashes from the app from end-users though (in the background automatically), and the Google Play error logs aren't sufficient for him, Acra might be a good solution. – Mathias Conradt Jun 09 '12 at 16:07
  • 1
    It seems from the reviews that aLogrec hasn't kept up with android and no longer works due to lack of request for root. Last update of the app was in 2012. – Tim Abell Nov 05 '15 at 18:33
2

From slashfoo's blog, (check the logcat page for exact syntax) hook up your computer to start off the logcat process in the background. adb shell nohup logcat -f /dev/[your sdcard] -n60 -r3600

Although it means logcat will be saved to the sdcard but every time you reboot, you must perform the procedure again.

likejudo
  • 3,396
  • 6
  • 52
  • 107
0

Use the alogrec program. It writes the log to the SD card, and will automatically resume after rebooting.

0

Updating for 2019, Fabric, which was purchased by Google, does an excellent job of remote logging app crashes. Integration into the app was simple, and it is free (at least at whatever level I'm using it). It has been extremely valuable to finding defects in my apps.

https://www.fabric.io

Dan
  • 473
  • 3
  • 7
-1

Try to open a terminal/command prompt and issue this in it :
adb -d logcat
This should dump you a live version of the logcat you could read to find the problem

Sephy
  • 50,022
  • 30
  • 123
  • 131
  • 3
    Sorry if I didn't make it clear in the question, but this isn't possible as I don't want to carry my computer around with me constantly until it crashes :P Was just hoping there was a way of saving logcat to sd or something. – stealthcopter Jul 29 '10 at 19:48