Navigating the Console
Google Developers Logo

Progressive Web App Dev Summit

June 20-21, Amsterdam, NL - Watch Now

Learn how to: open the DevTools Console, stack redundant messages or display them on their own lines, clear or persist output or save it to a file, filter output, and access additional Console settings.

TL;DR

  • Open the Console as a dedicated panel or as a drawer next to any other panel.
  • Stack redundant messages, or display them on their own lines.
  • Clear or persist output between pages, or save it to a file.
  • Filter output by severity level, by hiding network messages, or by regular expression patterns.

Opening the Console

Access the Console as a full-screen, dedicated panel:

The Console panel

Or as a drawer that opens next to any other panel:

The Console drawer

Open as panel

To open the dedicated Console panel, either:

  • Press Ctrl+Shift+J (Windows / Linux) or Cmd+Opt+J (Mac).
  • If DevTools is already open, press the Console button.

When you open the Console panel, the Console drawer collapses automatically.

Open as drawer

To open the Console as a drawer next to any other panel, either:

  • Press Esc while DevTools is in focus.
  • Press the Customize and control DevTools button and then press Show console.

Show console

Message stacking

If a message is consecutively repeated, rather than printing out each instance of the message on a new line, the Console “stacks” the messages and shows a number in the left margin instead. The number indicates how many times the message has repeated.

Message stacking

If you prefer a unique line entry for every log, enable Show timestamps from the DevTools settings.

Show timestamps

Since the timestamp of each message is different, each message is displayed on its own line.

Timestamped console

Working with the Console history

Clearing the history

You can clear the console history by doing any of the following:

  • Right-click in the Console and press Clear console.
  • Type clear() in the Console.
  • Call console.clear() from within your JavaScript code.
  • Type Ctrl+L (Mac, Windows, Linux).

Persisting the history

Enable the Preserve log checkbox at the top of the console to persist the console history between page refreshes or changes. Messages will be stored until you clear the Console or close the tab.

Saving the history

Right-click in the Console and select Save as to save the output of the console to a log file.

Save Console to log file

Selecting the right target

By default, logging and error output from frames or extensions contained within a page will not be output to the Console. You can access other frames’ Console output by using the dropdown at the top of the console. An <iframe> element, for example, would create its own frame context, selectable from this menu.

Frame selection

Filtering the Console output

Click the Filter button (filter button) to filter console output. You can filter by severity level, by a regular expression, or by hiding network messages.

Filtered Console output

Filtering by severity level is equivalent to the following:

OptionShows
AllShows all console output
ErrorsOnly show output from console.error().
WarningsOnly show output from console.warn().
InfoOnly show output from console.info().
LogsOnly show output from console.log().
DebugOnly show output from console.timeEnd() and console.debug().

Additional settings

Open the DevTools settings, go to the General tab, and scroll down to the Console section for further Console settings.

Console settings

SettingDescription
Hide network messagesBy default, the console reports network issues. Turning this on instructs the console to not show logs for these errors. For example, 404 and 500 series errors will not be logged.
Log XMLHttpRequestsDetermines if the console logs each XMLHttpRequest.
Preserve log upon navigationPersists the console history during page refreshes or navigation.
Show timestampsPrepends a timestamp to each console message showing when the call was made. Useful for debugging when a certain event occurred. This will disable message stacking.
Enable custom formattersControl the formatting of JavaScript objects.
Authors
Profile photo of Kayce Basques
Kayce Basques

Technical Writer at Google

Profile photo of Meggin Kearney
Meggin Kearney

Meggin is a Tech Writer

Profile photo of Paul Bakaus

Open Web Developer Advocate at Google • Tools, Performance, Animation, UX

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code samples are licensed under the Apache 2.0 License. For details, see our Terms of Service.

Previous
Using the Console
Next
Diagnose and Log to Console