Logs for extension pages displayed as a tab, such as override pages and full-page options, can be found in the web page console and on the extensions management page.
Run In Background. Run Chrome in the background continuously. This extension simply keeps Chrome running in the background, so that push notifications can be received while the browser is closed.
You can open the background page's console if you click on the "background.html" link in the extensions list.
To access the background page that corresponds to your extensions open Settings / Extensions
or open a new tab and enter chrome://extensions
. You will see something like this screenshot.
Under your extension click on the link background page
. This opens a new window.
For the context menu sample the window has the title: _generated_background_page.html
.
Any extension page (except content scripts) has direct access to the background page via chrome.extension.getBackgroundPage()
.
That means, within the popup page, you can just do:
chrome.extension.getBackgroundPage().console.log('foo');
To make it easier to use:
var bkg = chrome.extension.getBackgroundPage();
bkg.console.log('foo');
Now if you want to do the same within content scripts you have to use Message Passing to achieve that. The reason, they both belong to different domains, which make sense. There are many examples in the Message Passing page for you to check out.
Hope that clears everything.
To answer your question directly, when you call console.log("something")
from the background, this message is logged, to the background page's console. To view it, you may go to chrome://extensions/
and click on that inspect view
under your extension.
When you click the popup, it's loaded into the current page, thus the console.log should show log message in the current page.
You can still use console.log(), but it gets logged into a separate console. In order to view it - right click on the extension icon and select "Inspect popup".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With