serge
serge

Reputation: 15219

Filter the Chrome console messages

Is there a way to filter messages in the Chrome console?
By example, I don't want to see messages from/containing the JQMIGRATE...

Upvotes: 47

Views: 32276

Answers (5)

Akaisteph7
Akaisteph7

Reputation: 6426

To exclude multiple different expressions, you can use regular strings, regexes, or URLs. They each target different parts of the console and different filter levels differently.

Plain strings are the easiest to use and will target any part of the console messages

-insight -ads

Regular regexes work fine

/insight/ /ads/

But for some reason, more complex negative loookaheads will only target the source file of the message and only warnings and errors at that... Using spaces to separate filters did not work for me previously either, so this may just be another bug.

/^((?!insight|ads).)*$/

URLs target the URL being interacted with. It only targets the source file if the message is not caused by a fetch request.

-url:https://connect.facebook.net/en_US/fbevents.js

Upvotes: 0

Coquelicot
Coquelicot

Reputation: 9093

You can negate filters by prepending with -. For example, -JQMIGRATE will exclude messages containing the string "JQMIGRATE".

Regex filters can also be negated this way. e.g. -/^DevTools/ will exclude messages that begin with "DevTools".

(Credit goes to Donald Duck, who suggested this in a comment on the chosen answer. I thought it was a far cleaner solution than negative lookaheads, and deserved to be elevated to a top-level answer.)

Upvotes: 68

Brad
Brad

Reputation: 515

I've found this to simple filter all console messages from extensions. This will also persist until you clear the filter. Type -chrome-extension:. This will REMOVE any messages that come from -> chrome-extension: <- urls.

You can use multiple filters by putting a space between each query. Ex. -chrome-extension: -cookie. Notice the space after the : and before the -c. This will REMOVE any messages that come from -> chrome-extension: <- urls and also REMOVE any messages with cookie in the context.

Using Chrome Version 80.0.3987.132 (Official Build) (64-bit)

Chrome Filter Useage

Upvotes: 13

Octobadger
Octobadger

Reputation: 143

The accepted answer works for single line filtering, but I found it also filters out any multi-line logs. See the following examples.


No filter:

No Filter


Accepted answer (missing multi-line logs):

Accepted answer - missing multi-line logs


Fixed negative filter (correctly keeps multi-line logs):

/^((.|\s)(?!Violation))+$/

Fixed negative filter


Bonus! Easy filtering out multiple matches:

/^((.|\s)(?!Violation|creating))+$/

Bonus! Easy filtering out multiple matches

Upvotes: 6

SVSchmidt
SVSchmidt

Reputation: 6517

I think you can. Recent chrome versions allow filtering using regular expressions by enclosing the search pattern in /.../, previous versions had a checkbox. You can express, for instance, "not bar" by using negative lookaheads, as described here How to negate specific word in regex?

In the picture below, I tried filtering for "not bar".

Example: Filtering for "not bar"

Upvotes: 19

Related Questions