title: Strategies to JavaScript console.log/trace, etc
body: <p>I am writing a rather large JavaScript software. I need to trace calls, log events, debug actions, while maintain performance and portability across browsers.</p>
  
  <p>Webkit and Firebug both offer console object with methods like trace(), log(), error(), warning(), etc. They are great, but what do I do when the browser is IE or Opera?</p>
  
  <p>Imagine having a big application, you surely want to see all initializations it is doing, events it is making, etc., thus I make it log those. However, if I just log those, the logging will not work in browsers that do not have <em>console</em> registered in the DOM. I could create a wrapper object:</p>
  
  <pre><code>MyNamespace.Console = {};
  MyNamespace.Console.log = function(value) {
   if (console!==undefined) {
    console.log(value);
   }
   else {
    // What should I do to log events on other browsers?
   }
  }
  </code></pre>
  
  <p>The above makes so no problems occur on IE / Opera, but how do I log with IE (one really needs logging with IE!).</p>
  
  <p>Also, if I plant logs everywhere in my application, does it slow me down when it is being run on a production environment? Should I have a switch DEBUG on/off and a simple check before logging that if DEBUG===true, then log?</p>
  
  <p>What about systems like Closure Compiler, can you make them to remove logging?</p>
  
  <p>What if there is an error while running on production environment and logging has not happened, how do you debug/find the problem? And in fact, do you ever send JavaScript error logs to you (developer), to make sure your clients are not having problems? How does that work out?</p>
  
  <p>I appreciate any feedback/comments on debugging/logging with JavaScript, this is my first time writing a huge JavaScript application, and frankly, I am not sure what should I do about this... debugging and logging in JavaScript seems a bit unfinished.</p>