Validation errors and expected errors such as handled errors
are common and they're expected to happen frequently, so they shouldn't interrupt the system in any way whatsoever.
Therefore they should not be seen in logs. They can be shown in the access logs.
Unexpected errors should be logged with the highest priority (error). These errors should be monitored, prevented, and handled.
#### System state changes
Back-end apps strive to be stateless but they also do have some state like:
- served endpoint, port
- database connection
- 3rd party integrations
Changes in the system with valuable information should be logged with the `info` level. They serve as a great source of information about the system prior to the failure.
#### Debug
Don't be hesitant to use `debug` logs. They can always be turned off or turned on back again while debugging.
Most of the time developers tend to use `console.log` and then remove it before committing.
I'd encourage you to use `debug` level and leave it there.
It can be a big help in the future which can point you to the part of the code which is responsible for the manipulation of the data.
### 4. Don't log sensitive information
**Never, ever log credentials, passwords, or any sensitive information.**
## Front-end
Front-end logging is fundamentally different from the back-end.
There is a new instance of the program for every opened window and it is only opened for 1 particular client.
Developers should **not** expose the functionality to users.
There is an _npm package_ [debug](https://www.npmjs.com/package/debug) that
enables developers to write debug logs that persist in the codebase.