this method fetch , dump logs in sdcard android. working fine, wondering if can put filter trace logs related specific tags. idea ?
tried logcat -s *tagiwant;
didn't work. other suggestion ?
public static void log(context context){ string filename = context.getexternalfilesdir(null).getpath() + file.separator + "my_app.log"; string command = "logcat -d *:v"; log.d(tag, "command: " + command); try{ process process = runtime.getruntime().exec(command); bufferedreader in = new bufferedreader(new inputstreamreader(process.getinputstream())); string line = null; try{ file file = new file(filename); file.createnewfile(); filewriter writer = new filewriter(file); while((line = in.readline()) != null){ writer.write(line + "\n"); } writer.flush(); writer.close(); } catch(ioexception e){ e.printstacktrace(); } } catch(ioexception e){ e.printstacktrace(); } }
try { process process = runtime.getruntime().exec("logcat -d"); bufferedreader bufferedreader = new bufferedreader(new inputstreamreader(process.getinputstream())); string line; pattern pattern = pattern.compile("xxx", 0); while ((line = bufferedreader.readline()) != null) { if (patternu != null && !pattern.matcher(line).find()) { continue; } log.append(line); log.append('\n'); } } catch (ioexception e) { }
Comments
Post a Comment