0

within my application I want to save the log to a file internally. I have used this : How to redirect my log output from logcat to the SD-Card on an android device?

and I do get a log file but the problem is that the log contains only logs that are related to my application , without logs from the entire device. meaning , the log file is relatively small...

my method is running from onDestroy and contains simply the following:

public static void WriteLog() throws IOException {
    String[] cmd = new String[] { "logcat","-d" , "-f", "/sdcard/Folder/LAUCHER_LOG.log", "-v", "threadtime"};
    Runtime.getRuntime().exec(cmd);
}
Community
  • 1
  • 1
yanish
  • 257
  • 2
  • 15

1 Answers1

1

To access all of LogCat, the app has to hold the READ_LOGS permission. Ordinary Android apps cannot hold this permission, as of Android 4.1 or 4.2. Only apps signed with the signing key that signed the firmware can hold this permission. In effect, that means that you can only hold this permission if you create your own custom Android ROM.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I do have this permission . you mean that the system ignores this permission? – yanish Mar 13 '16 at 12:41
  • @yanish: Correct. You can *request* whatever permissions you want via `` elements. You only *get* those permissions if the system agrees to. – CommonsWare Mar 13 '16 at 12:43