Doing any sort of development requires logging and dumping stuff to a console. Firefox extension development is no exception to this (Venkmann is useful, but he sure can be a pain).

There’s two ways that I know of to do this… The first outputs to a shell and the second uses the Error Console.

Using dump()
Firefox has a function called dump() that will just dump whatever you give it to a standard console. To use it you have to…

  • Start Firefox in console mode - from a command prompt type “/path_to_firefox_app/firefox -console”
  • Set “browser.dom.window.dump” to true in about:config - the excellent Extension Developer’s extension can do this for you.
  • Use dump("My message\n"); to dump to the console.

It isn’t pretty, but it works.

The Console Service
The other way is to use the console service, which will put debug statements into Firefox’s Error Console.


var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
        .getService(Components.interfaces.nsIConsoleService);
    consoleService.logStringMessage("My Message");

It’s easier, and requires less config, but it isn’t working so well for me right now. Sigh…

What we really need for logging in Firefox is a log4j style logging framework. That would be super sweet!