question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

inefficient use of loggers

See original GitHub issue

Issue #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:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
pspeed42commented, Nov 24, 2021

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.)

0reactions
vxelcommented, Nov 25, 2021

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}) and logger.log(Level.FINE, myobject1 + " " + myobject2)

is mostly aesthetic.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found