6

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.

3 Answers 3

6

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.

1

It seems that you have to add a subscription callback for $A.log to work:

$A.logger.subscribe( "INFO", function( level, message, error ) {
    console.log( message );
    console.log( error ); 
});
0

There are a number of other aura.mode values that are currently not exposed via force.com (unless you have a specific or perm enabled) id neither of the production modes will currently emit $A.log() messages. The primary difference between production and production debug is the level of minification and obfuscation we apply to JavaScript. We do plan to correct this in the near future.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .