DEV Community

Basit Ali Mundia
Basit Ali Mundia

Posted on

Logs in frontend apps

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?

Top comments (5)

Collapse
 
basitali profile image
Basit Ali Mundia

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.

Collapse
 
nektro profile image
Meghan (she/her) • Edited

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.

Collapse
 
basitali profile image
Basit Ali Mundia

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?
Collapse
 
davidszabo97 profile image
Dávid Szabó

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

Collapse
 
basitali profile image
Basit Ali Mundia

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.