본문 바로가기

Programming/Linux_Platform

logcat 사용법 정리

[adb] logcat [<option>] ... [<filter-spec>] ...

 

The following table describes the logcat command line options:

-c

Clears (flushes) the entire log and exits.

전체로그를 삭제하고 빠져나옵니다.

-d

Dumps the log to the screen and exits.

저장된 로그를 화면에 출력하고 종료한다.

-f <filename>

Writes log message output to <filename>. The default is stdout.

-g

Prints the size of the specified log buffer and exits.

로그버퍼의 사이즈를 출력

-n <count>

Sets the maximum number of rotated logs to <count>. The default value is 4. Requires the -roption.

로그가 저장되는 로그파일의 최대 갯수를 지정

-r <kbytes>

Rotates the log file every <kbytes> of output. The default value is 16. Requires the -f option.

각 로그파일이 가질수있는 사이즈 지정

위에 나오는 -n , -r 옵션은 -f옵션과 같이 써야만 실행되는 옵션입니다.

 

즉, adb logcat -f /mnt/sdcard/2222.txt -r 10 -n 7 

이렇게 명령어를 실행하면 2222.txt, 2222.txt1, 2222.txt2, 2222.txt3, 2222.txt4, 2222.txt5, 2222.txt6, 2222.txt7

총 7개의 파일이 생기고, 각 파일이 10kbytes가 꽉 차게되면 다음파일로 돌아가면서, 로그을 쌓게 됩니다.

 

-s

Sets the default filter spec to silent.

Silent를 기본 우선순위로 지정한다. (-s대신 *:S 도 사용가능)

*:W  --> warning 이상 출력

-v <format>

Sets the output format for log messages. The default is brief format. For a list of supported formats, see Controlling Log Output Format.
 

brief : 우선순위/태그 + PID

process : PID만

tag : 우선순위/태그만

thread : 프로세스:쓰레드 + 우선순위/태그

raw : 다른 데이터 없이 로그만 출력

time : 날짜 + 시간 + 우선순위/태그 + PID

long : 모든데이터를 출력하고 빈줄로 로그들을 구분함

 

 

-b <버퍼명> : main(기본) / radio / event 버퍼중에서 원하는걸 선택한다.

<buffer>

*radio: radio, telephony와 관련된 메시지

*events: 이벤트와 관련된 메시지

*main: 디폴트 메시지

 

*:W  --> warning 이상 출력

 

 

  • 아래로 갈수록 강한 메세지임
  • The priority is one of the following character values, ordered from lowest to highest priority:
  • V — Verbose (lowest priority)
  • D — Debug
  • I — Info
  • W — Warning
  • E — Error
  • F — Fatal

  • S — Silent (highest priority, on which nothing is ever printed)