News for hackers. Stuff that matters.
Re:My Logging Best Practices (2020) by raldi on Tuesday October 05, 2021 @12:48PM (#28761984)
Of course you always keep it on — the point of the different levels is that you can filter them out at read time (e.g. to eyeball logs, or to alert when the rate of >= WARN is too high)
Re:My Logging Best Practices (2020) by codemac on Tuesday October 05, 2021 @12:58PM (#28762115)
This traditionally has not been log level's use case.

syslog() and setlogmask() being the obvious examples.

Many (if not all) companies I have worked out filtered out everything DEBUG at compile time to improve performance in production as well.

The best option I've seen is putting everything in DEBUG or lower into a memory ring buffer per process that's dumped and collated with other logs at each ERROR/FATAL log.

Re:My Logging Best Practices (2020) by spockz on Tuesday October 05, 2021 @01:23PM (#28762503)
That is actually quite nifty. That way you can carry debug logs and only materialise/send them in case of errors when you are likely interested in it without having to put those logs at error and see them all the time etc.

Does anyone know of an implementation for this in any of the Java logging frameworks?

Re:My Logging Best Practices (2020) by hurflmurfl on Tuesday October 05, 2021 @05:39PM (#28765978)
I've actually used this idea in production and it worked great.

In my web app if nothing unexpected happens, only INFO/LOG level stuff is pushed to logs. If, however, I get an exception, I will instead print out all the possible traces. I.e. I always store all the logs in-memory and choose what should be printed out based on the success/failure of the request.

Now, of course, this is just a web API running in AWS Lambda, and I don't have to care overly much about the machine just silently dying mid-request, so this might not work for some of you, but this works great for my use-case and I'm sure it will be enough for a lot of people out there.

Re:My Logging Best Practices (2020) by masklinn on Tuesday October 05, 2021 @04:21PM (#28765080)
Fwiw sentry does that out of the box, anything below warning (I think) is used as context for “actual events”.
Re:My Logging Best Practices (2020) by snak on Tuesday October 05, 2021 @03:00PM (#28763983)
Performance degradation is noticeable with DEBUG level in production.
Re:My Logging Best Practices (2020) by raldi on Tuesday October 05, 2021 @04:01PM (#28764834)
Performance degradation is noticeable with excessive logging; the level is irrelevant.
Re:My Logging Best Practices (2020) by hacker_newz on Tuesday October 12, 2021 @05:01PM (#28845033)
Debug was not designed to always be left on. That's why you need to enable it in the first place.
Re:My Logging Best Practices (2020) by mplewis on Tuesday October 05, 2021 @04:01PM (#28764835)
Leaving debug levels on in production will bankrupt most companies.
Re:My Logging Best Practices (2020) by raldi on Tuesday October 05, 2021 @04:03PM (#28764862)
Re:My Logging Best Practices (2020) by sagichmal on Tuesday October 05, 2021 @10:46PM (#28768594)
Nope, this produces unmanageable log volume.
Re:My Logging Best Practices (2020) by raldi on Wednesday October 06, 2021 @01:04AM (#28769404)
How does making these DEBUG logs into INFO logs make the volume manageable?

Or, to flip that around, if you take a program that produces a manageable amount of INFO logs, and change some of those INFOs to DEBUGs, how does that suddenly become unmanageable?

Re:My Logging Best Practices (2020) by sagichmal on Friday October 08, 2021 @04:01PM (#28803531)
My point is that DEBUG level logging is (hopefully!) not on by default, and that this is what it makes the production log volume manageable.

My experience has been that 1 customer-facing byte tends to generate something like ~10 DEBUG-level telemetry bytes. This level of request amplification can't be feasibly sustained at nontrivial request volumes, your logging infrastructure would dwarf your production infrastructure.