Skip to content
AnswerWell geo Documentation

Research · 8 min read · Answerwell

Developer Console: Log Messages, Filtering, and JavaScript REPL

How the browser developer Console works: severity levels, console APIs, filtering, settings, and exporting logs for troubleshooting.

This page summarises Chrome DevTools documentation on the Console: viewing logged messages, running JavaScript on the live page, and tuning filters and settings. Lighthouse treats console Error messages as a best-practice signal. Cloudflare Support recommends saving a console log when browser-side failures (including CORS) do not show up clearly in a HAR export alone.

Console panel: what it is and when you need it

Section titled “Console panel: what it is and when you need it”

The Console is for testing and debugging JavaScript web applications. It has two main uses: viewing logged messages and running JavaScript.

Use the Console to test and debug Javascript web applications.

— Google, Console overview

Most browsers ship built-in developer tools that include a console. Messages come from the page’s JavaScript or from the browser. Each message has a severity level: Verbose, Info, Warning, or Error. An Error means there is a problem on the page you should resolve.

Messages logged in the console come from either the web developers who built the page or the browser itself. All console messages have a severity level: Verbose, Info, Warning, or Error. An Error message means there’s a problem on your page that you need to resolve.

— Google, Browser errors were logged to the console

Developers log to the Console to confirm code runs in the right order and to inspect variable values at a specific moment. The Console is also a REPL (Read, Evaluate, Print, Loop): it evaluates what you type, prints the result, and waits for the next input. Because it has full access to the page’s window, you can change the DOM or try fixes while debugging JavaScript—for example, evaluating expressions in scope while execution is paused.

On-device AI features in Chrome can also be inspected from the Console:

Use the Console to view and debug the results of on-device AI.

— Google, Artificial Intelligence in Chrome

Open the Console: panel, drawer, and shortcuts

Section titled “Open the Console: panel, drawer, and shortcuts”

You can open the Console as a panel or as a tab in the Drawer (press Escape while another panel is focused).

You can open the Console as a panel or as a tab in the Drawer.

— Google, Console features reference

To open the Console panel:

Press Control+Shift+J or Command+Option+J (Mac).

— Google, Console features reference

From the Command Menu, type Console and run Show Console (the entry with the Panel badge). While the Console is focused, Control+L or Command+K / Option+L clears it; Shift+Enter inserts a newline without running the command. See Console panel keyboard shortcuts.

Console API: how to log from your JavaScript

Section titled “Console API: how to log from your JavaScript”

Use the Console API from page scripts to write messages. DevTools assigns a severity level to most console.* methods so you can filter by level (Filter by log level).

Method Log level Typical use
console.debug() Verbose Same as console.log() but Verbose level
console.log(), console.info() Info General output
console.warn() Warning Non-fatal issues
console.error(), console.assert() when false Error Failures; console.error() includes a stack trace
console.trace() Info Explicit stack trace

Prints object to the Console, formats it as an error, and includes a stack trace.

— Google, Console API reference (console.error)

Other useful methods from the same reference:

  • console.table(array [, columns]) — tabular data; optional column names limit displayed fields.
  • console.group() / console.groupCollapsed() / console.groupEnd() — visual grouping of related lines.
  • console.time() / console.timeEnd() — labelled timers.
  • console.dir() / console.dirxml() — object or XML tree views.
  • console.count() / console.countReset() — invocation counts per label.

Clear from code with console.clear() — but if Preserve log is on, console.clear() is disabled (Console API reference).

For formatted output, use % specifiers (%s, %i, %d, %f, %o, %O, %c for CSS styling) as described in Format and style messages in the Console. With %c, the url() CSS function in styles supports only data: URLs, to reduce data-leak risk.

Hands-on introduction: Log messages in the Console and Viewing logged messages.

View messages: stack traces, network lines, and CORS

Section titled “View messages: stack traces, network lines, and CORS”

The Console automatically captures stack traces for errors and warnings (latest frame at the top). It can walk error cause chains and prefix stacks with Caused by: when errors are chained via cause.

Breakpoint-related output is marked distinctly: conditional breakpoint console.* calls show an orange ?; logpoints show pink .. (View messages from breakpoints).

Optional Console Settings (Console features reference, mirrored in DevTools Preferences):

Setting Effect
Log XMLHttpRequests Logs XHR and Fetch as requests run
Hide network Hides default network messages (e.g. 404 lines)
Show CORS errors in console Shows or hides CORS-related console errors; Network and Issues shortcuts beside errors
Group similar messages in console Groups duplicate lines
Preserve log Keeps messages across navigations; logs “Navigated to” on navigation

By default the Console clears on each full page load unless Preserve log is enabled.

Filter console output: level, text, URL, and context

Section titled “Filter console output: level, text, URL, and context”

Filtering affects output only; commands you typed remain (Filter messages).

Use the Log Levels dropdown or the Console Sidebar (Errors, Warnings, Info, Verbose). Level choices from the dropdown persist across pages and DevTools restarts; sidebar filters are temporary.

Filter by text, regular expression, or URL

Section titled “Filter by text, regular expression, or URL”
  • Text — type a string in the Filter box.
  • Regex — e.g. /pattern/; spaces use \s.
  • url: — messages from a script URL or domain; -url: excludes a URL.
  • User Messages in the Sidebar — only console.* from page scripts, hiding browser messages.

Enable Selected context only in Console Settings when an ad or other iframe floods the Console (Filter out messages from different contexts).

Console Utilities API: DevTools-only helpers

Section titled “Console Utilities API: DevTools-only helpers”

The Console Utilities API works only when invoked from the DevTools Console—not from production scripts.

These functions only work when you call them from the Chrome DevTools Console. They won’t work if you try to call them in your scripts.

— Google, Console Utilities API reference

Function Role
$(), $$(), $x() querySelector, querySelectorAll, XPath (optional startNode)
$0–$4 Last five Elements/Profiles selections
$_ Result of the last evaluated expression
inspect(), copy(), dir(), dirxml() Panel navigation and structured display
getEventListeners() Registered listeners on an object
monitor() / monitorEvents() Log function calls or DOM events (unmonitor* to stop)
keys() / values(), queryObjects() Object keys and constructor instances
debug(fn) Pause on first line of fn next call (Run JavaScript in the Console)

If a library such as jQuery defines $, the utility $ may be overridden (Console Utilities API).

DOM shortcuts from the Console are summarised under Access nodes in the Console; object inspection details appear in Inspect object properties and View the properties of DOM objects.

Live Expressions pin an expression to the top of the Console; the result updates about every 250 ms. Use Create Live Expression, enter the expression (multi-line with Shift+Enter), then Enter to save.

Eager evaluation previews return values as you type; disable it in Console Settings if previews distract (Disable Eager Evaluation). Treat code evaluation as user action sets user activation as if the user interacted (navigator.userActivation.isActive)—useful when testing APIs gated on activation (Preferences).

Ways to clear the UI (Clear the Console):

  • Clear console in the toolbar, Ctrl+L / Cmd+K, context menu Clear console, clear() in the Console, or console.clear() from the page (unless Preserve log blocks it).

From the context menu you can Copy console, Save as… (plaintext .log), expand/collapse all, and clear console history (not the same as clearing visible messages).

For support tickets when JavaScript errors, CORS, or cancelled requests are involved, Cloudflare advises a console export in addition to a HAR when the request never appears in the HAR:

Use a console log when you experience JavaScript errors, CORS issues, or when requests are blocked or cancelled by the browser.

— Cloudflare, Gathering information for troubleshooting sites

In Chrome: open Console, enable Preserve Log, reproduce the issue, then right-click and Save as log file (In Chrome).

  • Assuming console.clear() clears history when Preserve log is on—it is disabled in that mode.
  • Treating Console Utilities ($, monitorEvents) as APIs safe to ship in application code—they are DevTools-only.
  • Exporting support data with only a HAR when the browser blocked or cancelled the request before it was recorded—capture a preserved console log as Cloudflare describes.

Further reading: Console overview, Run JavaScript in the Console, Console features reference.

  1. Open Chrome DevTools (Control+Shift+J or Command+Option+J), load your page, and confirm whether Error or Warning messages appear.
  2. Enable Preserve log in Console Settings, navigate through the user flow again, and verify whether errors persist or only occur after specific steps (Persist messages across page loads).
  3. Filter to Errors only; expand a stack trace and use the source link to jump to the originating script (View stack traces).
  4. If you audit with Lighthouse, review the Browser errors were logged to the console audit and fix remaining Error-level console output.
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.