blob: b30971ef110907a3a822e95fcee9d94930d51739 [file] [log] [blame]
Scott Main50e990c2012-06-21 17:14:39 -07001page.title=logcat
2parent.title=Tools
3parent.link=index.html
4@jd:body
5
6 <p>The Android logging system provides a mechanism for collecting and viewing system debug
7 output. Logs from various applications and portions of the system are collected in a series of
8 circular buffers, which then can be viewed and filtered by the <code>logcat</code> command. You can use
9 <code>logcat</code> from an ADB shell to view the log messages.</p>
10
Dirk Doughertyfe57f382012-06-28 15:35:12 -070011 <p>For complete information about logcat options and filtering specifications, see
12 <a href="{@docRoot}tools/debugging/debugging-log.html">Reading and Writing Logs</a>.</p>
13
14 <p>For more information on accessing <code>logcat</code> from DDMS, instead of the command line, see
15 <a href="{@docRoot}tools/debugging/ddms.html">Using DDMS</a>. </p>
Scott Main50e990c2012-06-21 17:14:39 -070016
17 <h3>Syntax</h3>
18 <pre>
19[adb] logcat [&lt;option&gt;] ... [&lt;filter-spec&gt;] ...
20</pre>
21
22 <p>You can run <code>logcat</code> as an adb command or directly in a shell prompt
23 of your emulator or connected device. To view log output using adb, navigate to your SDK
24 <code>platform-tools/</code> directory and execute:</p>
25 <pre>
26$ adb logcat
27</pre>
28
29 <p>You can create a shell connection to a device and execute:</p>
30 <pre>
31$ adb shell
32# logcat
33</pre>
34
35 <h3>Options</h3>
36 <p>The following table describes the command line options of <code>logcat</code>.</p>
37
38 <table>
39 <tr>
40 <th>Option</th>
41
42 <th>Description</th>
43 </tr>
44
45 <tr>
46 <td><code>-b&nbsp;&lt;buffer&gt;</code></td>
47
John Spurlock6d9b0342014-03-13 12:40:12 -040048 <td>Loads an alternate log buffer for viewing, such as <code>events</code> or
Scott Main50e990c2012-06-21 17:14:39 -070049 <code>radio</code>. The <code>main</code> buffer is used by default. See <a href=
Dirk Doughertyfe57f382012-06-28 15:35:12 -070050 "{@docRoot}tools/debugging/debugging-log.html#alternativeBuffers">Viewing Alternative Log Buffers</a>.</td>
Scott Main50e990c2012-06-21 17:14:39 -070051 </tr>
52
53 <tr>
54 <td><code>-c</code></td>
55
56 <td>Clears (flushes) the entire log and exits.</td>
57 </tr>
58
59 <tr>
60 <td><code>-d</code></td>
61
62 <td>Dumps the log to the screen and exits.</td>
63 </tr>
64
65 <tr>
66 <td><code>-f&nbsp;&lt;filename&gt;</code></td>
67
68 <td>Writes log message output to <code>&lt;filename&gt;</code>. The default is
69 <code>stdout</code>.</td>
70 </tr>
71
72 <tr>
73 <td><code>-g</code></td>
74
75 <td>Prints the size of the specified log buffer and exits.</td>
76 </tr>
77
78 <tr>
79 <td><code>-n&nbsp;&lt;count&gt;</code></td>
80
81 <td>Sets the maximum number of rotated logs to <code>&lt;count&gt;</code>. The default value
82 is 4. Requires the <code>-r</code> option.</td>
83 </tr>
84
85 <tr>
86 <td><code>-r&nbsp;&lt;kbytes&gt;</code></td>
87
88 <td>Rotates the log file every <code>&lt;kbytes&gt;</code> of output. The default value is
89 16. Requires the <code>-f</code> option.</td>
90 </tr>
91
92 <tr>
93 <td><code>-s</code></td>
94
95 <td>Sets the default filter spec to silent.</td>
96 </tr>
97
98 <tr>
99 <td><code>-v&nbsp;&lt;format&gt;</code></td>
100
101 <td>Sets the output format for log messages. The default is <code>brief</code> format. For a
Dirk Doughertyfe57f382012-06-28 15:35:12 -0700102 list of supported formats, see <a href="{@docRoot}tools/debugging/debugging-log.html#outputFormat">Controlling Log Output
Scott Main50e990c2012-06-21 17:14:39 -0700103 Format</a>.</td>
104 </tr>
105 </table>