rocketraman commented on issue #136:
URL: 
https://github.com/apache/logging-log4j-kotlin/issues/136#issuecomment-3338444231

   This was added via https://github.com/apache/logging-log4j-kotlin/issues/29 
by @jvz .
   
   I have to admit, I'm not fond of the `logger` property either, as I prefer 
client code to be more explicit about loggers. In addition, the logger property 
introduces a function call on every access, and the user might not be cognizant 
of the performance impact of this, which is real. According to our benchmarks, 
`companionObjectLookupInterfaceDirect` and 
`companionObjectExtensionPropertyFunctional` which both use the logger property 
(and thereby the getter function) are 15-20 times slower than all the other 
methods:
   
   ```
   Benchmark                                                    Mode  Cnt   
Score   Error  Units
   LoggingBenchmark.companionObjectExtensionPropertyDirect      avgt   10   
0.826 ± 0.028  ns/op
   LoggingBenchmark.companionObjectExtensionPropertyFunctional  avgt   10   
0.817 ± 0.003  ns/op
   LoggingBenchmark.companionObjectKotlinLoggerDirect           avgt   10   
0.817 ± 0.008  ns/op
   LoggingBenchmark.companionObjectKotlinLoggerFunctional       avgt   10   
0.814 ± 0.004  ns/op
   LoggingBenchmark.companionObjectLog4jLoggerDirect            avgt   10   
0.603 ± 0.005  ns/op
   LoggingBenchmark.companionObjectLog4jLoggerFunctional        avgt   10   
0.604 ± 0.005  ns/op
   LoggingBenchmark.companionObjectLookupInterfaceDirect        avgt   10  
13.736 ± 0.021  ns/op
   LoggingBenchmark.companionObjectLookupInterfaceFunctional    avgt   10  
13.730 ± 0.032  ns/op
   LoggingBenchmark.topLevelLoggerWithContextLookupDirect       avgt   10   
0.814 ± 0.004  ns/op
   LoggingBenchmark.topLevelLoggerWithContextLookupFunctional   avgt   10   
0.815 ± 0.003  ns/op
   LoggingBenchmark.topLevelNamedLoggerDirect                   avgt   10   
0.813 ± 0.003  ns/op
   LoggingBenchmark.topLevelNamedLoggerFunctional               avgt   10   
0.814 ± 0.009  ns/op
   ```
   
   I would be in favor of adding an `_logger` (or equivalently less 
discoverable name) property with an equivalent implementation, deprecating the 
`logger` property now (with appropriate documentation), and then removing 
`logger` in the next major version. That gives people who really want it the 
ability to use it via `_logger`, but users hopefully won't end up with it by 
mistake.
   
   But would like to hear opinions from @jvz since he was the one that added 
this originally.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to