Hacker News new | ask | show | jobs
by octonaut 493 days ago
I agree with everything said here, but I'd like to add a couple of extra points:

- Be aware of the volume of logs you generate. For e.g. if you're in a for loop iterating over a thousand elements, and have a try/catch on processing each element, you're going to generate a thousand lines of logs if there's an upstream issue (database connection error, network error etc.). In such cases, always exit early when you have an unrecoverable error. And I don't necessarily mean exit the whole program, just exit the loop early.

- If you're logging to file, make sure you have a log rotation policy in place with a maximum file config set. In a previous workplace we had a system wide outage because a core component got wiped out because it got too many connection errors, wrote the errors to disk, filled up all the space and took the box down.