I have an android application that I have published on the Market. Some customers have reported compatibility issues with certain devices. I believe that I need to look at the LogCat for these devices to spot the issue. The problem is that I don't have those devices handy for testing.
Is there some way that I can enable the application to log the logcat output during the time its active? I know that I can add manual logging and write it to a file but I don't want to log output from only my application but everything from LogCat. I can then have the customers send me there log files for analysis.
If they have SDK installed just connect the phone and do:
adb logcat -d > logcat.txt
I don't think there's an "out of the box" solution on Android OS for what you want. It would be a security risk IMHO. There may be an app.
You can find a thread about this here: http://forum.xda-developers.com/showthread.php?t=543128
A way to handle this is to when the application has a crash or fails doing something (try..catch or if...) you can then save the stack to a file for users to send you, or send it automatically to your server (you should warn users of course)
As said in the other anwswer "there's an app for that": https://market.android.com/details?id=org.jtb.alogcat
This can also be useful: https://market.android.com/details?id=net.robotmedia.bugreporter An app that's really for Bug Reporting.
I was mistaken, you can catch logcat from inside your app:
Process logcat = Runtime.getRuntime().exec("logcat"); // start process BufferedReader reader = new BufferedReader( new InputStreamReader(logcat.getInputStream())); // grab output stream
This should be done in a separated thread.