Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logcat output on SDCard

Tags:

android

logcat

I'm looking for a way to save all the logcat output (Filter by tag) in phone memory/sd card. So even if someone who is playing with app, will come to me and say it crashes, or it doesn't work as intended, i could look into logs. I`m using RemoteLogs at the moment, but they not handle standard logcat output.

like image 521
Drake29a Avatar asked Dec 12 '25 19:12

Drake29a


1 Answers

I think this is not directly possible. What you could do it to override the standard Log.x() methods like this

class MyLog {
  boolean sdLog = false;

  public void d(String arg1, String arg2) {
    if (sdLog) {
       someLogFile.append(arg1).append(":").append(arg2);
    }
    else {
       Log.d(arg1,arg2);
    }
  }
}

and then in your code replace all calls to Log.d() with calls to MyLog.d(). The user can then e.g. in preferences select to log to the sd card or use the standard mechanism.

Generally logging everything to the SD card was not chosen (afair) by Android, as this would mean huge amounts of writes to the card, which would reduce its lifetime.

like image 175
Heiko Rupp Avatar answered Dec 15 '25 07:12

Heiko Rupp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!