Fork me on GitHub
#clojure-dev
<
2021-08-04
>
serioga13:08:28

Hello. Question about clojure.tools.logging.impl. In get-logger implementation we call (str logger-ns)

(reify LoggerFactory
          (name [_#]
            "org.slf4j")
          (get-logger [_# logger-ns#]
            (org.slf4j.LoggerFactory/getLogger ^String (str logger-ns#))))
This str is called every time from enabled?. As result disabled levels like (log/trace ...) utilise ~30 ms just in testing for enabled?. Can this code be improved so that disabled log levels cost as little as possible?

serioga13:08:11

Well, probably I'm wrong and slow part is org.slf4j.LoggerFactory/getLogger is the slowest part...

serioga13:08:19

It would be great to avoid repetitive computations for every log statement in single namespace...

ghadi13:08:20

need a fuller problem reproduction

seancorfield16:08:27

@serioga Since the Clojure code in tools.logging is just delegating to one of a number of Java libraries, and it is inside those Java libraries that the decision about disabled log levels is done, based on their configuration, I'm not sure how much "delegation overhead" you're going to be able to get rid of. I'd say that if you really care about logging performance and the overhead of disabled log levels, you should either not put logging calls in performance-critical code or not use tools.logging and do Java interop directly, or both.