I understand that I can log to the console when using a Firefox extension with the cfx run
command.
Is there a way to log to a console after the extension has been packaged with cfx xpi
? Logging to Firebug is fine if possible.
I have found two blog posts about this (here and here). Both are rather old and don't work any more.
I'm using version 1.10 of the add-on SDK and FF15.
You need to do 2 things:
enable logging for addons
• in about:config, add a new option "extensions.sdk.console.logLevel" and give it the value "all"
• restart Firefox
in Firefox open the Browser Console:
• Tools -> Web developer -> Browser console
• NOTE: this is different from the usual Web Console used to debug web pages
You should see addons logs there now.
TLTR:
about:config
url and create keyextensions.sdk.console.logLevel
with valueall
cfx
or its successorjpm
creates this configuration key automatically in development firefox profile.From logging documentation:
Have you tried
console.log()
with Firebug? (I know you have triedApplication.console.log()
andFirebug.console.log()
already)I just tried it in the Web Console on FF16 running Firebug 1.10.4 and it seems to work:
Here are some more examples from the Firebug Wiki itself: FirebugWiki Console API
Additionally, you can write messages of different types in the console, such as:
console.debug()
,console.info()
,console.warn()
,console.error()
If you run console.log from Add-on code, it send up in the 'Messages' tab of the Error Console window: