[SalesForce] Salesforce1 Lightning Debug “log()” method not working

I've enabled Debug mode in lightning components.
When I tried to use

$A.log("This is a log message");

in controller (javascript), I'm not able to see the logs in Javascript Console of the browser. Please let me know if I need to turn on any other feature.

Best Answer

You shouldn't have to turn on anything else as far as I can tell.

You can see that when the Enable Debug Mode is checked the JavaScript file aura_proddebug.js is loaded and used and when it is not checked aura_prod.js is loaded and used and the debug version isn't even loaded. (That's consistent with the documentation and expected).

You can step through the aura_proddebug.js fairly easily with a JavaScript debugger such as Chrome's debugger and see that a function $A.$ns$.$Aura$.prototype.$logInternal$ is called, but doesn't do anything.

If you need to log for now, you could always write your own log function that delegates to console.log, if present, and then later change the function implementation to use $A.log.

$A.warning doesn't work also, which makes sense because it is essentially the same function as the log/info level logging, but just at a different level. $A.error works, but it is completely different in that it pops the exception overlay.

Related Topic