-
Notifications
You must be signed in to change notification settings - Fork 16
Logging configuration #109
Comments
Also consider using Timbre intead of log4j. |
Timbre is convenient but it does not work with existing loggers. For one of projects that used Timbre I had to write adapter to have unified logging from Timbre, Jetty and other libraries https://github.com/PetrGlad/timbre-over-slf4j If this solves what you want o achieve, then go on. Also you can change logging levels right now (Log4j 2.x) see https://logging.apache.org/log4j/2.x/faq.html#reconfig_level_from_code (require '[org.zalando.stups.friboo.log :as log])
(import org.apache.logging.log4j.core.config.Configurator)
(import org.apache.logging.log4j.Level)
(Configurator/setLevel "user" Level/TRACE) ;
(log/trace "Hello")
(Configurator/setLevel "user" Level/INFO) ;
(log/trace "Hello") |
@PetrGlad wouldn't |
@PetrGlad that's interesting, because we already have In a nutshell, my problem is: I want to set I'd like to have more intuitive way of configuring logging, and also including a resource in the library isn't a very good practice, because some apps might want to include their own |
@sebastianpoeplau there are multiple adapters of logging frameworks' APIs (at least for all usual suspects JUL, Log4j and JCL) on one hand and logging implementations for slf4j on the other. Since Friboo already contains several adapters directly to Log4j v2 logger [org.apache.logging.log4j/log4j-api "2.7"]
[org.apache.logging.log4j/log4j-slf4j-impl "2.7"] ;; <<<<<<<<<<<
[org.apache.logging.log4j/log4j-jcl "2.7"]
[org.apache.logging.log4j/log4j-1.2-api "2.7"]
[org.apache.logging.log4j/log4j-jul "2.7"] no need to change that: with an adapter Timbre will log to slf4j which would log to log4j. For my projects I'd prefer to stay with clojure.tools.logging though. |
@dryewo Friboo template could provide some default configuration file. If The use case I care about is application deployed in a container. The configuration there is normally passed via environment variables. With log4j one can put placeholders in configuration file that will be filled from environment (see section "Property Substitution"). But this does not allow to configure levels for arbitrary loggers (e.g. 3rd party libraries). |
@sebastianpoeplau I probably misunderstood the question. Timbre is logging implementation that has own logger and is completely oblivious to the java ecosystem out there. That's the problem. No choice of logging framework inside Friboo would change the fact that 3rd party libraries already use loggers.
Actually it buys you Jetty, for example :) |
I just checked Timbre again, now they have implemented a slf4j appender. |
@PetrGlad my understanding is that we actually want to use Timbre at the base, rather than deferring to some Java logger. That's why I mentioned that there are bindings to redirect to Timbre whatever third parties log to some of the well-known Java frameworks. |
OK. What problem do you want to solve by using Timbre? |
The only valid point I see here in Timbre is zero-configuration in case of stdout logging. Apart from that don't have a definite opinion, because I'm not sure how timbre handles heavy load and other "sensitive" logging topics. |
I would love to have the freedom of choosing a logging implementation, which would mean choosing the way of configuring it as well. So I think benefits of using Timbre is a separate discussion. Existing libraries, from my experience, use slf4j mostly, so there should be no problem with that. Also I would prefer to log objects instead of strings and send them to Reimann for monitoring and to ELK for analysis. p.s. this setup works fine with
|
Use https://github.com/malcolmsparks/clj-logging-config instead of providing
resources/log4j.xml
. This should allow to configure logging in runtime.The text was updated successfully, but these errors were encountered: