inefficient use of loggers
See original GitHub issueIssue #1672 drew my attention to inefficient use of loggers in JMonkeyEngine. A quick scan found dozens of instances that can probably be improved. A common anti-pattern is code that constructs a log message using string concatenation, as in GltfUtilities
:
logger.log(Level.WARNING, "Unsupported Vertex Buffer type " + attribute);
Most of these should be refactored.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Poor Logging Practice | OWASP Foundation
It is a poor logging practice to use multiple loggers rather than logging levels in a single class. Good logging practice dictates the...
Read more >Netbeans hint "Inefficient use of string concatenation in logger"
There reason to use arguments instead of concatenation is to avoid the string creation if the log level is higher than INFO. All...
Read more >Insufficient Logging and Monitoring: Ultimate Guide 2022
What Is Insufficient Logging and Monitoring · Unlogged events and transactions · Missing log backups · Obscure error logging · Missing breach ...
Read more >Poor Logging Practice: Use of a System Output Stream
When the use of system output streams is jumbled together with the code that uses loggers properly, the result is often a well-kept...
Read more >Avoid These 9 Logging Problems in Your Java Application
1. Logging Sensitive Information · 2. Excessive Logging · 3. Cryptic Log Messages · 4. Using a Single Log File · 5. Choosing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
WARNING is a bad example because it is almost always enabled and so the check is redundant.
Whatever crappy-JUL’s version of INFO is… that’s sort of on the fence. Finer than that should either be gated or use the pattern version. (I prefer gating in general if a conversion is being done because that pattern idiom has an argument limit before it’s no better than concatenating a string.)
Oh yes it is.
Btw, I now understand the point of @pspeed42 regarding the personal style. If the statement is already gated, then the difference between
logger.log(Level.FINE, "{0} {1}", new Object[]{myobject1, myobject2})
andlogger.log(Level.FINE, myobject1 + " " + myobject2)
is mostly aesthetic.