You can log to the Firefox console by using the method "dump" in javascript. To enable this feature in Firefox type in about:config in the address bar and create there a new boolean entry with the name "browser.dom.window.dump.enabled" and the value "true".
Now start Firefox from the command line by entering "firefox -console". All messages passed to dump() will be printed on the command line.
To automatically add a timestamp to your messages and avoid error messages in other browsers I've created this little function:
function log(message) {
if(window.dump) {
var date = new Date();
var hours = date.getHours();
if(hours < 10) hours = "0" + hours;
var minutes = date.getMinutes();
if(minutes < 10) minutes = "0" + minutes;
var seconds = date.getSeconds();
if(seconds < 10) seconds = "0" + seconds;
dump(hours + ":" + minutes + ":" + seconds + " - someapp: " + message + "\n");
}
}