Hi James, this was a “convention” started at first by the Infinispan team, but then applied across several projects. There’s certainly tradeoffs, and perhaps it’s time to revisit them as I don’t know how much it’s applicable today, but this was intentional. Essentially expressing it as a final constant has two benefits (which might be out of date):
- it helps code elimination in GraalVM
- the performance help in JVM - like you say, it’s extemely marginal but it has been show to exist, and in some cases it matters.
Now as it happens, both of the above points are highly contexctual, but we had some situations in which they did matter. The alternative to this pattern being to fully remove such statements from the source code. Rather than fully removing it, we decided that we consider the “trace” level as something that is allowed to be folded as a constant. So I’d not consider it as a bug because if people want to “flip” this dynamically… if I remove such statements instead they won’t be able to log them at all. Perhaps JBoss Logger could address this need explicitly? As I see it, what puzzles our users most is that this “convention” isn’t advertised enough. What we could do, if these are particularly useful, is to re-evaluate if they should be upgraded to debug. It wasn’t intention to fold as a constant anything at debug level, only for tracing. |