Fork me on GitHub
#clojure-uk
<
2019-09-29
>
dharrigan07:09:10

Good Morning!

dharrigan08:09:46

clojure.tools.logging uses slf4j if found on the classpath (as preference). I'm curious, and this may be symptomatic of clojure compiling on-the-fly (if no genclass is used), if I use the L pattern to indicate Linenumber in the configuration of slf4j, the linenumbers do not match the sourcecode. I suppose because of macro expansion, dynamic compliation, etc., that goes on. Would I be right? Is it useless to try and get the number output in the log when using clojure? What do others do?

seancorfield16:09:29

@dharrigan when I tried that recently I always got the same line number in every log output line and my reading of the log4j2 docs suggested a) it would always be the line number of the actual call into the Java layer (ie., inside the logging wrapper) and b) it introduces quite an overhead to compute it anyway. So we abandoned that idea and just ensure our log calls have unique strings within any given namespace.

dharrigan18:09:43

@seancorfield thanks for that. I've come to the same conclusion, that line numbers in this case are not useful. I've removed the encoder pattern for line numbers.

seancorfield18:09:55

The log4j2 docs say both filename and line number can be expensive to compute. The classname is OK tho' (namespace in Clojure). Not sure if that applies to slf4j as well, but I suspect it does.

dharrigan18:09:19

indeed! 🙂