I'm trying to save only the important logs of my app to keep a record that should be saved in a cloud service but I do not know how to do it properly. Currently saving all the logs and filtering them by the package name of my app, but there are some logs belonging to my app that are not shown with this method, any recommendations? thank you!
StringBuilder log = new StringBuilder();
try{
Process process = Runtime.getRuntime().exec("logcat -d");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
while (((line = bufferedReader.readLine()) != null) ) {
if(line.contains("<NAMEOFPACKAGEAPP>")) {
log.append(line);
log.append(System.getProperty("line.separator"));
}
}
} catch (IOException e) {
e.printStackTrace();
}