Logs in frontend apps

twitter logo github logo ・1 min read

I was having a discussion with my team and wanted to have everyone thoughts on how they configured logging in their frontend apps.

I happen to just reset console.log to an empty function on production builds but leave the warn and error in place.

But, is there any use of having logs enabled on production at all?

twitter logo DISCUSS (5)
markdown guide
 

For frontend, specially when talking to an API, I feel there are several other things to keep in mind. For e.g. API failure (due to network issues and maybe session expiring) is not necessarily an issue with the app and does not need to be logged.

 

I'm not from them, but have you seen one of this month's sponsors, Timber? They specialize in logging and may be worth a look.

 

A quick glance at their page feels like they focus on the backend logging which is the whole point of the discussion.

  1. Unlike backend and unless you push the logs to a server, logs in the frontend app makes no sense at all.
  2. Frontend failures can be caused by factors outside of the app ranging from networks/firewall issues, content blockers or even malwares in the clients machine. How do you effectively log errors in such cases?
 

Have you thought about pushing error logs to a server on production?

 

Yep, that's definitely the next step. But the first part is silencing the logs I already have. And then, filtering logs that are worth pushing to server.

Classic DEV Post from Jun 12

What are your favorite Linux utility/productivity tools?

Basit Ali Mundia profile image
Full Stack Dev with working experience on Native (iOS/Android/RN), Frontend (React/Angular/Vue) and Backend (Python/Express/SpringBoot) apps.