4 ms·
At least in Java, log levels don't buy you much when you wind up possibly rendering object graphs to strings (via your ohsohelpful custom, recursive tostring im
by mml 12y ago
At least in Java, log levels don't buy you much when you wind up possibly rendering object graphs to strings (via your ohsohelpful custom, recursive tostring implementation), then duping it to concat "made it here" to it, then immediately abandon the mess on the heap for the gc to handle, since the production log level is warn, so your carefully built, highly detailed log message is never used. Repeat every other line or so... In tight loops, call iter.next in log message and on and on...
- thrownaway2424 12y agoSome java servers I have had the misfortune of diagnosing were found to be spending the majority of their CPU time (aside from garbage collection of course) formatting exception stack traces.
- idunno246 12y agowhich is why slf4j has format strings
- yummyfajitas 12y agoThat's not a java problem, that's an "I don't understand Java logging" problem. The right way: log.debug("I created this gigantic object {}", myBigUglyObject)
- egwor 12y ago... or your recursive reflective tostring implementation....
- arethuza 12y ago"possibly rendering object graphs to strings" But that's a problem with how you choose to use logging in your application - not with logging in general or specific logging features in Java. Logging used without any care can cause lots of problems - but then so can any part of an application. Used with some care it can be a very useful tool for helping to diagnose all kinds of problems.