Reputation: 22643
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.
Upvotes: 21
Views: 21430
Reputation: 1790
It seems the default debugging experience has improved a bit. Following the Firefox documentation, no special configuration is needed to get logged messages:
about:debugging
.You'll get complete debugger tools for your extension, including the console.
Upvotes: 2
Reputation: 1233
You need to do 2 things:
• in about:config, add a new option extensions.sdk.console.logLevel
and give it the value "all"
• restart Firefox
• 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.
Upvotes: 35
Reputation: 143
I will summarize recent changes that has taken with Firefox since this question got posted -- basically updated @LucaBonavita answer.
In about:config, check if option extensions.sdk.console.logLevel
is enabled. If not, toggle to enable. You might need to create it if it does not exist
Open Browser Console
Show Content Messages
in browser console.Now, console.log
triggered by Firefox addon/extension should display
Tested on Firefox 94.0.2 (64-bit) and 95.0b12 (64-bit)
Upvotes: 2
Reputation: 16624
TLDR:
about:config
url and create key extensions.sdk.console.logLevel
with value all
cfx
or its successor jpm
creates this configuration key automatically in development firefox profile.
From logging documentation:
extensions.sdk.console.logLevel
: if set, this determines the logging level for all installed SDK-based add-ons.
extensions.extensionID.sdk.console.logLevel
, where extensionID is an add-on's Program ID. If set, this determines the logging level for the specified add-on. This overrides the global preference if both preferences are set.
Upvotes: 7
Reputation: 5830
If you run console.log from Add-on code, it send up in the 'Messages' tab of the Error Console window:
Upvotes: -1
Reputation: 5440
Have you tried console.log()
with Firebug? (I know you have tried Application.console.log()
and Firebug.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()
Upvotes: 0