33

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

SuperStormer
  • 4,997
  • 5
  • 25
  • 35
serge
  • 13,940
  • 35
  • 121
  • 205
  • I think messages from JQMIGRATE are there for a reason, and in turn, removed once you've migrated (upgraded to a newer jQuery I think?) & removed the JQMIGRATE plugin. – brandito Jul 16 '18 at 03:36
  • Since chrome 94 you can do this with a simple invert check box next to the network tab search. – AnandShiva Jan 15 '22 at 06:59

4 Answers4

47

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.)

Coquelicot
  • 8,775
  • 6
  • 33
  • 37
  • Very useful! Is there any way to filter based on multiple words? The error message I get doesn't have a word that isn't used in other error messages. I tried to add quotes around the sentence but that didn't work for me – Y. Gherbi Nov 30 '21 at 21:06
  • 8
    @Y.Gherbi in the regex, you can type `\s` to signify whitespace, `-/^DevTools\sfailed/` filters out all lines starting with "DevTools failed". – Wolfzoon Dec 23 '21 at 16:41
  • Great comment! This should be front and center – user2403232 May 03 '22 at 21:06
17

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"

SVSchmidt
  • 6,269
  • 2
  • 26
  • 37
  • 1
    Doesn't work for me. I have storybook running and by default it prints out some messages like "message arrived at manager..." -- I tried to turn this off by typing what you showed above: /^(?!.*message).*$/ -- still all messages are shown, no effect. – Darko Maksimovic Nov 28 '19 at 14:37
  • 13
    You don't need to use `?!` in this case. To filter out only the word `bar`, it's enough to do `-bar` (without regexes). You can also use the `-` on a regex, for example you can do `-/foo\sbar/`. – Donald Duck Feb 29 '20 at 12:26
11

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

Brad
  • 485
  • 5
  • 10
6

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

farmer-Bri
  • 143
  • 2
  • 6
  • How to mix those? For example I already have there something like: "-url:http://example.com" and now want to add a regular expression. How to do it? – Onkeltem Jan 28 '20 at 11:14