0

I know save logcat to file.txt in android But I wanna filter logcat in output. For example I just wanna write all logcat except I:info to text file. How can I do that. Here my code to save logcat, It's writing all info( above priority V(verbose)) to file.

private void logFile(){
    try {
        File[] storages =  getExternalMediaDirs();
        String path = storages[1] + "/"+ DeviceConfig.getInstance().getDeviceID() + "_log.txt"; //save file to my SDCard

        Runtime.getRuntime().exec(new String[]{
                "logcat", "-f", path, "MyappTAG:V"
        }); //write all logcat 
    } catch (IOException e) {
        Log.d(TAG,"Logcat Error: " + e);
    }
}

tks for any help

Jamebes
  • 96
  • 8
  • "above priority V(verbose)" -- that's not correct. If you want to print everything, then use Verbose tag (V), less verbose is Debug (D), and lastly Info (I). Anyway, you can add multiple filters as arguments -- `"MyappTAG:I", "MyappTAG:E"` – Darkman Oct 05 '22 at 08:10

0 Answers0