page.title=logcat Monitor parent.title=Android Monitor parent.link=android-monitor.html page.tags=monitor @jd:body

In this document

  1. logcat Message Format
  2. Displaying a Running App in the logcat Monitor
  3. Setting the Log Level
  4. Searching logcat Messages
  5. Filtering logcat Messages
  6. Configuring the logcat Header Display
  7. Moving Up and Down the Stack Trace
  8. Moving to the End of the Log
  9. Printing the Log
  10. Clearing the Log
  11. Restarting the Log

See also

  1. Reading and Writing Logs
  2. Android Monitor
  3. Memory Monitor
  4. CPU Monitor
  5. GPU Monitor
  6. Network Monitor

Dependencies and Prerequisites

The Android logging system provides a mechanism for collecting and viewing system debug output. logcat Monitor displays messages that you added to your app by using the Log class, as well as system messages, such as stack traces when the emulator throws an error or a garbage collection occurs. The monitor displays messages in real time and also keeps a history so you can view older messages.

To display just the information of interest, you can create filters, modify how much information is displayed in messages, set priority levels, display messages produced by app code only, and search the log. By default, logcat Monitor shows the log output related to the running application only.

You can traverse the stack trace when your app throws an exception, as well as view the associated code. This feature can help you fix exceptions and improve app operation.

logcat Message Format

Every Android log message has a tag and a priority associated with it. The tag of a system log message is a short string indicating the system component from which the message originates (for example, ActivityManager). A user-defined tag can be any string that you find helpful, such as the name of the current class (the recommended tag). You define it in a Log method call, for example:

Log.d(tag, message);

The priority is one of the following values:

The log message format is:

date time PID-TID/package priority/tag: message

For example, the following log message has a priority of V and a tag of AuthZen:

12-10 13:02:50.071 1901-4229/com.google.android.gms V/AuthZen: Handling delegate intent.

PID stands for process identifier and TID is thread identifier; they can be the same if there’s only one thread.

Displaying a Running App in the logcat Monitor

Follow these steps:

  1. Optionally connect a hardware device.
  2. Display Android Monitor.
  3. Click the logcat tab.
  4. Open an app project and run it on a hardware device or emulator.
  5. By default, the logcat Monitor displays messages for the app running on the device or emulator:

    To change this default, see Filtering logcat Messages.

Setting the Log Level

You can control how many messages appear in logcat Monitor by setting the log level. You can display all messages, or just the messages indicating the most severe conditions.

Remember that logcat Monitor continues to collect all messages regardless of the log level setting. The setting just determines what logcat Monitor displays.

Follow this step:

Searching logcat Messages

You can search the messages currently displayed in logcat Monitor. Follow these steps:

  1. Optionally select Regex if you want to use a regular expression search pattern.
  2. Type a character sequence in the search field Search icon.
  3. The logcat Monitor display changes accordingly.

  4. Press Enter to store the sequence in the menu during this session.
  5. To repeat a search, choose it from the search menu. Select or deselect Regex as needed (the setting isn’t remembered).

Filtering logcat Messages

One way to reduce the log output to a manageable level is to restrict it by using a filter.

Note: The filter applies to your full logcat history, not just those messages currently displayed in logcat Monitor. Make sure your other display options are set appropriately so you can see the filter output you want to examine.

To define and apply a filter, follow these steps:

  1. In the filter menu, select a filter option:

    After you define filters, you can also select them in the menu. To remove them from the menu, delete them.

  2. If you selected Edit Filter Configuration, create or modify a filter.
    1. Specify the filter parameters in the Create New Logcat Filter dialog:
      • Filter Name - Type the name of a filter you want to define, or select it in the left pane to modify an existing filter. The name can contain lowercase characters, underscores, and digits only.
      • Log Tag - Optionally specify a tag. For more information, see logcat Message Format.
      • Log Message - Optionally specify log message text. For more information, see logcat Message Format.
      • Package Name - Optionally specify a package name. For more information, see logcat Message Format.
      • PID - Optionally specify a process ID. For more information, see logcat Message Format.
      • Log Level - Optionally select a log level. For more information, see Setting the Log Level.
      • Regex - Select this option to use regular expression syntax for that parameter.
    2. Click + to add it to the left pane.
    3. To remove a filter, select it in the left pane and click -.

    4. When you’re finished, click OK. If you click Cancel, any filter additions or modifications are lost.

Configuring the logcat Header Display

You can customize the header display to show just the information you’re interested in:

For more information about message elements, see logcat Message Format.

Moving Up and Down the Stack Trace

When the app throws an exception, the message includes a stack trace of method calls. logcat Monitor lets you quickly locate stack traces in the log and view the associated code in the Code Editor. If needed (and possible), the decompiler derives source code that you can view.

Moving to the End of the Log

Clicking a particular message stops the display of messages. You can quickly move to the end of the log to see the real-time message flow.

Printing the Log

Follow these steps:

  1. Click Print Print icon.
  2. In the Print dialog, optionally change print parameters, and then click Print.

Clearing the Log

To clear (flush) the entire log, follow this step:

Restarting the Log

If there is a problem and the log is no longer progressing, you can restart the log. Follow this step: