Default Log files

When developing your own module in Magento, it’s useful to pass variables and other messages out to a debug file so you can see how your module is working with its data. Magento comes with 2 built in log files, system.log & exception.log, both located in the var/log folder. To activate them, you must go to the Magento admin panel and under: System->Configuration->Developer->Log Settings, you will see a setting for enabling the logs.

system.log is used for general debugging and catches almost all log entries from Magento, including warning, debug and errors messages from both native and custom modules.
exception.log is reserved for exceptions only, for example when you are using try-catch statement.
To output to either the default system.log or the exception.log see the following code examples:

Mage::log('My log entry');
Mage::log('My log message: '.$myVariable);

Custom Log Files

Going through the system.log can be a nightmare, with dozens of other modules outputting to the log it can be like finding the proverbial, needle in a haystack. So why not create a custom log for your module!, With Magento its so easy:

Mage::log('My log entry', null, 'mylogfile.log');
//pass a variable
Mage::log('My Variable: '.$myVar, null, 'mylogfile.log');

And that’s all there is to it. You can pass variable, arrays, messages to yourself, whatever you want. Just be careful when outputting native Magento objects, as they can be really really big. (Don’t ever try to output and entire product object!)
So now you have the equivalent of console.log() in javascript for your new mage application. Please drop me a line if this has worked for you, and remember to comment out your debug log statements before you output for production.