| page.title=logcat |
| parent.title=Tools |
| parent.link=index.html |
| @jd:body |
| |
| <p>The Android logging system provides a mechanism for collecting and viewing system debug |
| output. Logs from various applications and portions of the system are collected in a series of |
| circular buffers, which then can be viewed and filtered by the <code>logcat</code> command. You can use |
| <code>logcat</code> from an ADB shell to view the log messages.</p> |
| |
| <p>For complete information about logcat options and filtering specifications, see |
| <a href="{@docRoot}tools/debugging/debugging-log.html">Reading and Writing Logs</a>.</p> |
| |
| <p>For more information on accessing <code>logcat</code> from DDMS, instead of the command line, see |
| <a href="{@docRoot}tools/debugging/ddms.html">Using DDMS</a>. </p> |
| |
| <h3>Syntax</h3> |
| <pre> |
| [adb] logcat [<option>] ... [<filter-spec>] ... |
| </pre> |
| |
| <p>You can run <code>logcat</code> as an adb command or directly in a shell prompt |
| of your emulator or connected device. To view log output using adb, navigate to your SDK |
| <code>platform-tools/</code> directory and execute:</p> |
| <pre> |
| $ adb logcat |
| </pre> |
| |
| <p>You can create a shell connection to a device and execute:</p> |
| <pre> |
| $ adb shell |
| # logcat |
| </pre> |
| |
| <h3>Options</h3> |
| <p>The following table describes the command line options of <code>logcat</code>.</p> |
| |
| <table> |
| <tr> |
| <th>Option</th> |
| |
| <th>Description</th> |
| </tr> |
| |
| <tr> |
| <td><code>-b <buffer></code></td> |
| |
| <td>Loads an alternate log buffer for viewing, such as <code>events</code> or |
| <code>radio</code>. The <code>main</code> buffer is used by default. See <a href= |
| "{@docRoot}tools/debugging/debugging-log.html#alternativeBuffers">Viewing Alternative Log Buffers</a>.</td> |
| </tr> |
| |
| <tr> |
| <td><code>-c</code></td> |
| |
| <td>Clears (flushes) the entire log and exits.</td> |
| </tr> |
| |
| <tr> |
| <td><code>-d</code></td> |
| |
| <td>Dumps the log to the screen and exits.</td> |
| </tr> |
| |
| <tr> |
| <td><code>-f <filename></code></td> |
| |
| <td>Writes log message output to <code><filename></code>. The default is |
| <code>stdout</code>.</td> |
| </tr> |
| |
| <tr> |
| <td><code>-g</code></td> |
| |
| <td>Prints the size of the specified log buffer and exits.</td> |
| </tr> |
| |
| <tr> |
| <td><code>-n <count></code></td> |
| |
| <td>Sets the maximum number of rotated logs to <code><count></code>. The default value |
| is 4. Requires the <code>-r</code> option.</td> |
| </tr> |
| |
| <tr> |
| <td><code>-r <kbytes></code></td> |
| |
| <td>Rotates the log file every <code><kbytes></code> of output. The default value is |
| 16. Requires the <code>-f</code> option.</td> |
| </tr> |
| |
| <tr> |
| <td><code>-s</code></td> |
| |
| <td>Sets the default filter spec to silent.</td> |
| </tr> |
| |
| <tr> |
| <td><code>-v <format></code></td> |
| |
| <td>Sets the output format for log messages. The default is <code>brief</code> format. For a |
| list of supported formats, see <a href="{@docRoot}tools/debugging/debugging-log.html#outputFormat">Controlling Log Output |
| Format</a>.</td> |
| </tr> |
| </table> |