info:To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---
# Client-side logging for frontend development
This guide contains the best practices for client-side logging for GitLab
frontend development.
## When to log to the browser console
We do not want to log unnecessarily to the browser console, as excessively
noisy console logs are not easy to read, parse, or process. We **do** want to
give visibility to unintended events in the system. If a possible but unexpected
exception occurs during runtime, we want to log the details of this exception.
These logs can give significantly helpful context to end users creating issues, or
contributors diagnosing problems.
Whenever a `catch(e)` exists, and `e` is something unexpected, log the details.
### What makes an error unexpected?
Sometimes a caught exception can be part of normal operations. For instance, third-party
libraries might throw an exception based on certain inputs. If we can gracefully
handle these exceptions, then they are expected. Don't log them noisily.
For example:
```javascript
try{
// Here, we call a method based on some user input.
// `doAThing` will throw an exception if the input is invalid.
constuserInput=getUserInput();
doAThing(userInput);
}catch(e){
if(einstanceofFooSyntaxError){
// To handle a `FooSyntaxError`, we just need to instruct the user to change their input.
// This isn't unexpected, and is part of normal operations.