Logcat 参数及功能介绍
个人最常用的logcat 指令大致就有 -c , -t, -v, 但有个新需求,需要获取近期 *min 内的LOG,那么通过logcat -h 就可以展示具体有哪些指令,一起学习记录一下.
rk3288:/ $ logcat -h
Usage: logcat [options] [filterspecs]
options include:
-s Set default filter to silent. Equivalent to filterspec '*:S'
-f <file>, --file=<file> Log to file. Default is stdout
-r <kbytes>, --rotate-kbytes=<kbytes>
Rotate log every kbytes. Requires -f option
-n <count>, --rotate-count=<count>
Sets max number of rotated logs to <count>, default 4
--id=<id> If the signature id for logging to file changes, then clear
the fileset and continue
-v <format>, --format=<format>
Sets log print format verb and adverbs, where <format> is:
brief help long process raw tag thread threadtime time
and individually flagged modifying adverbs can be added:
color descriptive epoch monotonic printable uid
usec UTC year zone
Multiple -v parameters or comma separated list of format and
format modifiers are allowed.
-D, --dividers Print dividers between each log buffer
-c, --clear Clear (flush) the entire log and exit
if Log to File specified, clear fileset instead
-d Dump the log and then exit (don't block)
-e <expr>, --regex=<expr>
Only print lines where the log message matches <expr>
where <expr> is a regular expression
-m <count>, --max-count=<count>
Quit after printing <count> lines. This is meant to be
paired with --regex, but will work on its own.
--print Paired with --regex and --max-count to let content bypass
regex filter but still stop at number of matches.
-t <count> Print only the most recent <count> lines (implies -d)
-t '<time>' Print most recent lines since specified time (implies -d)
-T <count> Print only the most recent <count> lines (does not imply -d)
-T '<time>' Print most recent lines since specified time (not imply -d)
count is pure numerical, time is 'MM-DD hh:mm:ss.mmm...'
'YYYY-MM-DD hh:mm:ss.mmm...' or 'sssss.mmm...' format
-g, --buffer-size Get the size of the ring buffer.
-G <size>, --buffer-size=<size>
Set size of log ring buffer, may suffix with K or M.
-L, --last Dump logs from prior to last reboot
-b <buffer>, --buffer=<buffer> Request alternate ring buffer, 'main',
'system', 'radio', 'events', 'crash', 'default' or 'all'.
Multiple -b parameters or comma separated list of buffers are
allowed. Buffers interleaved. Default -b main,system,crash.
-B, --binary Output the log in binary.
-S, --statistics Output statistics.
-p, --prune Print prune white and ~black list. Service is specified as
UID, UID/PID or /PID. Weighed for quicker pruning if prefix
with ~, otherwise weighed for longevity if unadorned. All
other pruning activity is oldest first. Special case ~!
represents an automatic quicker pruning for the noisiest
UID as determined by the current statistics.
-P '<list> ...', --prune='<list> ...'
Set prune white and ~black list, using same format as
listed above. Must be quoted.
--pid=<pid> Only prints logs from the given pid.
--wrap Sleep for 2 hours or when buffer about to wrap whichever
comes first. Improves efficiency of polling by providing
an about-to-wrap wakeup.
filterspecs are a series of
<tag>[:priority]
where <tag> is a log component tag (or * for all) and priority is:
V Verbose (default for <tag>)
D Debug (default for '*')
I Info
W Warn
E Error
F Fatal
S Silent (suppress all output)
'*' by itself means '*:D' and <tag> by itself means <tag>:V.
If no '*' filterspec or -s on command line, all filter defaults to '*:V'.
eg: '*:S <tag>' prints only <tag>, '<tag>:S' suppresses all <tag> log messages.
If not specified on the command line, filterspec is set from ANDROID_LOG_TAGS.
If not specified with -v on command line, format is set from ANDROID_PRINTF_LOG
or defaults to "threadtime"
-v <format>, --format=<format> options:
Sets log print format verb and adverbs, where <format> is:
brief long process raw tag thread threadtime time
and individually flagged modifying adverbs can be added:
color descriptive epoch monotonic printable uid usec UTC year zone
Single format verbs:
brief — Display priority/tag and PID of the process issuing the message.
long — Display all metadata fields, separate messages with blank lines.
process — Display PID only.
raw — Display the raw log message, with no other metadata fields.
tag — Display the priority/tag only.
thread — Display priority, PID and TID of process issuing the message.
threadtime — Display the date, invocation time, priority, tag, and the PID
and TID of the thread issuing the message. (the default format).
time — Display the date, invocation time, priority/tag, and PID of the
process issuing the message.
Adverb modifiers can be used in combination:
color — Display in highlighted color to match priority. i.e. VERBOSE
DEBUG INFO WARNING ERROR FATAL
descriptive — events logs only, descriptions from event-log-tags database.
epoch — Display time as seconds since Jan 1 1970.
monotonic — Display time as cpu seconds since last boot.
printable — Ensure that any binary logging content is escaped.
uid — If permitted, display the UID or Android ID of logged process.
usec — Display time down the microsecond precision.
UTC — Display time as UTC.
year — Add the year to the displayed time.
zone — Add the local timezone to the displayed time.
"<zone>" — Print using this public named timezone (experimental).
在ADB窗口使用