마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

로그캣(logcat) 내용을 이용할 수 있나요?

0 추천
로그캣에서 나오는 내용을 사용할 수 있나요?

 

즉 제가 제작하는 어플리케이션에서 로그캣의 내용을 가져다 사용할 수 있는지 궁금합니다.

 

혹은 로그캣에 나오는 내용들을 전부 함수 혹은 리시버 같은것으로  접근이 가능한 것들인가요?
오로잭슨 (390 포인트) 님이 2014년 1월 17일 질문

1개의 답변

+1 추천
 
채택된 답변

로그는 

<uses-permission android:name="android.permission.READ_LOGS" />

퍼미션을 쓰고 

try {  
    ArrayList<String> commandLine = new ArrayList<String>();  
commandLine.add( "logcat");  
    commandLine.add( "-d");  
    commandLine.add( "-v");  
    commandLine.add( "time");  
    commandLine.add( "-s");  
    commandLine.add( "tag:W");  
    Process process = Runtime.getRuntime().exec( commandLine.toArray( new String[commandLine.size()]));  
    BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(process.getInputStream()), 1024);  
    String line = bufferedReader.readLine();  
    while ( line != null) {  
        log.append(line);  
        log.append("\n")  
    }  
} catch ( IOException e) {  
}

이렇게 읽으면 됩니다

출처 : http://stackoverflow.com/questions/10249207/why-cant-i-read-the-logcat-output-in-my-program

북이 (3,360 포인트) 님이 2014년 1월 17일 답변
오로잭슨님이 2014년 1월 17일 채택됨
...