Salesforce Interview Questions & Answers Book is now available!

Grab Now

LWC

Customise console.log() when working with LWC

Let's look at how to customise console.log() statement.

By Teja, ex-Salesforce engineer · Updated January 14, 2021 · 1 min read

When you work with LWC we have to use console.log() to debug the data.

Without this feature it becomes very hard to debug the data.

When you have lot of debug statements to look at, then it becomes very hard to differentiate one set of logs from another set.

Did you know that we can apply styles to console.log() such that it becomes a bliss to work with the logs in console.

Here is how you do it!

console.log('%c HEY! SALESFORCECASTS!!!! ', 'background: #222; color: #bada55');

Open you browser (Chrome), right click anywhere within the browser, click on inspect(a panel opens ups), now click on console tab with in the opened panel.

Copy and paste the code in the console panel of your browser and see what happens.

Learn it by building it

Every course, every code repository, the discussion group and certificates of completion — one subscription.

Keep me in the loop!

Email me when a new episode is published (promise, I will not spam you)

You're signing up to receive emails from Salesforce Casts