forked from clj-holmes/clj-watson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suppress some ERRORs logged by Apache Commons JCS
Closes clj-holmes#78
- Loading branch information
Showing
4 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
(ns clj-watson.logging-config | ||
(:require [clojure.string :as str]) | ||
(:import [org.slf4j LoggerFactory] | ||
[ch.qos.logback.classic.turbo TurboFilter] | ||
[ch.qos.logback.classic Level LoggerContext] | ||
[ch.qos.logback.core.spi FilterReply])) | ||
|
||
(defn- create-custom-filter | ||
"Suppress noise from Apache Commons JCS | ||
- It's INFO level messages are overly noisy, only log when minimum of WARN. | ||
- Suppress specific ERROR level messages from IndexedDiskCache that we have deemed unimportant. | ||
These suppresssions could be achieved with Logback's EvaluatorFilter but that requires a | ||
dependency on the Janino library. We'd like to avoid adding dependencies if possible." | ||
[] | ||
(proxy [TurboFilter] [] | ||
(decide [marker logger level format params throwable] | ||
(cond (and (= Level/ERROR level) | ||
(= "org.apache.commons.jcs3.auxiliary.disk.indexed.IndexedDiskCache" | ||
(.getName logger)) | ||
format | ||
(str/includes? format "Not alive and dispose was called")) | ||
FilterReply/DENY | ||
|
||
(and (< (.toInt level) Level/WARN_INT) | ||
(str/starts-with? (.getName logger) "org.apache.commons.jcs3")) | ||
FilterReply/DENY | ||
|
||
:else | ||
FilterReply/NEUTRAL)))) | ||
|
||
(defn init | ||
"Complement `resources/logaback.xml` with some customizations" | ||
[] | ||
(.addTurboFilter (LoggerFactory/getILoggerFactory) (create-custom-filter))) | ||
|
||
(comment | ||
(.toInt Level/WARN) | ||
;; => 30000 | ||
(.toInt Level/INFO) | ||
;; => 20000 | ||
|
||
:eoc) |