1page.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 11 <p>This document is a reference to the available command line options. For more information on <code>logcat</code>, see 12 <a href="{@docRoot}guide/developing/debugging/debugging-log.html">Reading and Writing Logs</a>. 13For more 14 information on accessing <code>logcat</code> from DDMS, instead of the command line, see the documentation for the 15 <a href="{@docRoot}guide/developing/debugging/ddms.html">Dalvik Debug Monitor Server</a>. 16 </p> 17 18 <h3>Syntax</h3> 19 <pre> 20[adb] logcat [<option>] ... [<filter-spec>] ... 21</pre> 22 23 <p>You can run <code>logcat</code> as an adb command or directly in a shell prompt 24 of your emulator or connected device. To view log output using adb, navigate to your SDK 25 <code>platform-tools/</code> directory and execute:</p> 26 <pre> 27$ adb logcat 28</pre> 29 30 <p>You can create a shell connection to a device and execute:</p> 31 <pre> 32$ adb shell 33# logcat 34</pre> 35 36 <h3>Options</h3> 37 <p>The following table describes the command line options of <code>logcat</code>.</p> 38 39 <table> 40 <tr> 41 <th>Option</th> 42 43 <th>Description</th> 44 </tr> 45 46 <tr> 47 <td><code>-b <buffer></code></td> 48 49 <td>Loads an alternate log buffer for viewing, such as <code>event</code> or 50 <code>radio</code>. The <code>main</code> buffer is used by default. See <a href= 51 "#alternativebuffers">Viewing Alternative Log Buffers</a>.</td> 52 </tr> 53 54 <tr> 55 <td><code>-c</code></td> 56 57 <td>Clears (flushes) the entire log and exits.</td> 58 </tr> 59 60 <tr> 61 <td><code>-d</code></td> 62 63 <td>Dumps the log to the screen and exits.</td> 64 </tr> 65 66 <tr> 67 <td><code>-f <filename></code></td> 68 69 <td>Writes log message output to <code><filename></code>. The default is 70 <code>stdout</code>.</td> 71 </tr> 72 73 <tr> 74 <td><code>-g</code></td> 75 76 <td>Prints the size of the specified log buffer and exits.</td> 77 </tr> 78 79 <tr> 80 <td><code>-n <count></code></td> 81 82 <td>Sets the maximum number of rotated logs to <code><count></code>. The default value 83 is 4. Requires the <code>-r</code> option.</td> 84 </tr> 85 86 <tr> 87 <td><code>-r <kbytes></code></td> 88 89 <td>Rotates the log file every <code><kbytes></code> of output. The default value is 90 16. Requires the <code>-f</code> option.</td> 91 </tr> 92 93 <tr> 94 <td><code>-s</code></td> 95 96 <td>Sets the default filter spec to silent.</td> 97 </tr> 98 99 <tr> 100 <td><code>-v <format></code></td> 101 102 <td>Sets the output format for log messages. The default is <code>brief</code> format. For a 103 list of supported formats, see <a href="#outputformat">Controlling Log Output 104 Format</a>.</td> 105 </tr> 106 </table> 107