Level up your JavaScript browser logs with these console.log() tips

Ackshaey Singh
8 min readNov 2, 2020
Banner image depicting ninjas

I consider myself a backend software engineer — and as any backend engineer would attest, a large part of our life is spent monitoring, troubleshooting, and debugging our applications. The fundamental rule of software development is that software will fail — what separates new developers from experienced ones is how they plan for those failures. Robust and effective logging is an important part of planning for failure, and eventual mitigation. As it is for backend development, logging can be useful for frontend software development, but it goes much further than just troubleshooting and debugging. Effective frontend logging can also make the development experience productive, fast, and fun.

While I’m a big proponent and diligent practitioner of Test-driven development, I love the flexibility, the richness of information, and code confidence browsers provide to frontend developers who make effective use of console.log(). I thought I’d share some frontend logging tips and tricks I’ve learned and incorporated in my workflow over time while building Firecode.io — in the hope that some of these will help you make your development workflow a bit more productive and fun!

I like to divide these tips into two broad categories — quick n’ dirty logging for when you’re actively building and debugging your application, and durable production logging — to know when your app’s working as expected and when it’s not.

Tips for quick n’ dirty development logging with console.log()

Don’t use console.log().

Yes, that’s right. I don’t use console.log(). Well, ok I write wrappers that use console.log() (more on that in the production logging section), but if you want to log something in your app to see what’s going on, use console.trace() instead. In addition to giving you everything console.log() does, it also outputs the entire stack trace so you know where exactly the message is emitted from.

Code

Use ES6’s computed property names to identify your objects…

--

--

Ackshaey Singh

Founder @ firecode.io / designerdiscount.club | Ex Staff SWE / Manager @Opendoor | Ex @Twitter Ads Engineering