amperity / dialog

Simple just-enough logging library for Clojure
MIT License
39 stars 2 forks source link

Can't disable logging from "com.zaxxer.hikari.util.DriverDataSource" via initialize! #26

Closed ieugen closed 2 years ago

ieugen commented 2 years ago

Hi @greglook ,

I think I found a bug, related to : https://github.com/amperity/dialog/issues/23

I tried with initialize! and I can't seem to mask "com.zaxxer.hikari.util.DriverDataSource" . Setting the level via (dialog.logger/set-level! "com.zaxxer.hikari.util.DriverDataSource" :info) works just fine.

p.s. I tried with both dialog commit 1dda8ccdd5172113c126df2a0c5dd1ae31332127 and also my slf4j-2 branch.

I have a project that uses github.com/stuartsierra/component and hikari db pooling library.

I start the app and I see this line:

13:11:16.041 [nREPL] DEBUG com.zaxxer.hikari.util.DriverDataSource  Loaded driver with class name org.postgresql.Driver for jdbcUrl=REDACTED

Adding line to dialog.edn + reloading config does not change logging in existing repl. Repl needs to be restarted for this to work.

{ :level :debug
 :levels {"dre" :info
          "io.netty" :info
          "com.zaxxer.hikari.pool" :info
          "org.apache.jena" :info
          "com.amazonaws" :info
          "com.zaxxer.hikari.HikariConfig" :error
          }
 :blocked #{"org.apache.http"
            "org.apache.parquet"
            "software.amazon.awssdk.profiles.internal.ProfileFileReader"
            "com.amazonaws.auth.profile.internal.BasicProfileConfigLoader"}
 :outputs {:dev {:type :print
                 :stream :stdout
                 :format :pretty
                 :padding false
                 :timestamp :short}}}

My deps.edn :


                   amperity/dialog {:git/url "https://github.com/amperity/dialog"
                                                               :sha     "1dda8ccdd5172113c126df2a0c5dd1ae31332127"}
                                              org.slf4j/log4j-over-slf4j               {:mvn/version "1.7.30"}
                                              org.slf4j/jul-to-slf4j                   {:mvn/version "1.7.30"}
                                              org.slf4j/jcl-over-slf4j                 {:mvn/version "1.7.30"}

{:jvm-opts [ "REDACTED"
                  "-Dclojure.tools.logging.factory=clojure.tools.logging.impl/slf4j-factory"]}
greglook commented 2 years ago

The log message says it's coming from the logger named com.zaxxer.hikari.util.DriverDataSource, but the config file you show sets levels for com.zaxxer.hikari.pool and com.zaxxer.hikari.HikariConfig, neither of which matches the util segment in the logger. Does it work if you set a level for com.zaxxer.hikari.util or one of its parent loggers?

ieugen commented 2 years ago

Hi, That is my initial configuration. I then do:

I changed the level for "com.zaxxer.hikari.util.DriverDataSource" to :info / :error in dialog.edn Ran initialize! and checked config is loaded in dialog.logger/config . Stopped and started my system. Logging line is still in the logs

I tested this and it is a bug. set-level! works fine, but not reloading the full file with initialize!.
With initialize! configuration is loaded but not applied = logging line is visible after reload.

greglook commented 2 years ago

Ah, okay - I think this might be that initialize! needs to call reset-level-cache!: https://github.com/amperity/dialog/blob/3933260fec9c88068cf091aa47d6fd8999194499/src/clojure/dialog/logger.clj#L64-L66