Re: How can I dump log messages from Java code in Firefox extension?
Brett Zamir <[email protected]> Sat, 09 Jan 2010 16:37:37 +0800
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Message-ID | <[email protected]> |
On 1/9/2010 4:29 PM, Sachiko Yoshihama wrote:
> I can call a Java code I wrote from a Firefox extension written in
> JavaScrpit, using the workaround described at:
> https://developer.mozilla.org/en/Java_in_Firefox_Extensions
>
> But when I try to dump some debug messages by using Logger or
> System.out, nothing appears in the console of Firefox.
> What is a good way of recording log messages in JavaCode that is
> called from a Firefox extension?
>
> Just to be clear, what I mean by the console is the command-line
> window that shows up when you invoke firefox.exe with the "-console"
> option.
> I changed the value of "browser.dom.window.dump.enabled" to true, and
> I can successfully log messages by dump() in JavaScript code.
>
The Java System.out messages will appear in the Java Console, but yes,
not Firefox's own. You can enable the Java Console in Windows by Control
Panel->Java->Advanced->Java Console->Show console.
Or, within JavaScript, you can use the output of a Java method called by
LiveConnect and send the result to dump() or to Firefox's own console
(Tools->Error Console):
function logc (msg) {
var consoleServ =
Components.classes['@mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleService);
consoleServ.logStringMessage(msg);
}
best wishes,
Brett