48

I am working on push notifications and came upon an unfamiliar term:

service worker console.

I have read and used the term console log or web console in browser, but I am not familier with the term service worker console, and I didn't find appropriate answer after googling it.

Can anyone explain what is service worker console? How to access it in Google Chrome?

Saugat Bhattarai
  • 2,614
  • 4
  • 24
  • 33
  • Where did you see it? Can you provide a link, or copy-and-paste the context? – Bob Stein Aug 25 '16 at 10:58
  • I have not heard of the term. But service workers are to replace the appcache, you could try to look at `Developer tools -> Resources` in Chrome. Also it's possible it is only available in some dev/beta build of Chrome. – Matthias Aug 25 '16 at 11:02
  • Read the last paragraph of this article http://craig-russell.co.uk/2016/01/29/service-worker-messaging.html#.V77FjXV97qM – Saugat Bhattarai Aug 25 '16 at 11:55

2 Answers2

105

Go to chrome://serviceworker-internals

Choose any service worker and start it if not already started.

Click on Inspect!!

Boom! You have the console there!

Oded Breiner
  • 28,523
  • 10
  • 105
  • 71
Dhruv Batheja
  • 2,140
  • 1
  • 18
  • 16
12

If a page has a service worker, then that service worker's logs show in that page's JavaScript console. You can see the source of a log line on the right-hand side of the log:

log line sources

In the console, there is a select box to select the JavaScript context. This defaults to top (which means "show everything"), but you can select a more specific context for just the service worker:

selecting alternative context

jameshfisher
  • 34,029
  • 31
  • 121
  • 167
  • Thanks! This seems like a much easier approach than the accepted answer, may also be worth noting that `self.console.log` [is needed](https://github.com/GoogleChrome/workbox/issues/1482) from certain parts of the worker. – Greg Venech Oct 19 '22 at 02:04