Here’s a logging format that I use and probably you should too. Among other things, it gets around most of the context issues by outputting the file and line number of the code that called the log.
Before I would try and make every log message unique or mostly unique so there weren’t double ups.
I don’t agree with the authors logging clutter though. If you’re manually eyeballing the logs looking for a message you’re already doing it wrong. Use search, have ids in the messages etc.
Remember folks, debug logging on because if it’s not logged, when it breaks you don’t have the logs…
That would be the levelname part. But if your log aggregator or subsystem is hindering your ability to use your logs, I would look to solve that problem before worrying about anything within your application.
Even storing logs in a format that you need to decode or download would be a red flag for me. Seconds of debugging all of a sudden turns into minutes or even hours.
Here’s a logging format that I use and probably you should too. Among other things, it gets around most of the context issues by outputting the file and line number of the code that called the log.
Before I would try and make every log message unique or mostly unique so there weren’t double ups.
I don’t agree with the authors logging clutter though. If you’re manually eyeballing the logs looking for a message you’re already doing it wrong. Use search, have ids in the messages etc.
Remember folks, debug logging on because if it’s not logged, when it breaks you don’t have the logs…