https://github.com/strojure/slf4j-mdc
Clojure utility for SLF4J logging system's MDC (Mapped Diagnostic Context)
https://github.com/strojure/slf4j-mdc
clojure logging mdc slf4j
Last synced: 6 months ago
JSON representation
Clojure utility for SLF4J logging system's MDC (Mapped Diagnostic Context)
- Host: GitHub
- URL: https://github.com/strojure/slf4j-mdc
- Owner: strojure
- License: unlicense
- Created: 2022-06-03T13:56:33.000Z (over 3 years ago)
- Default Branch: default
- Last Pushed: 2023-03-09T14:33:24.000Z (almost 3 years ago)
- Last Synced: 2025-07-10T15:13:44.749Z (6 months ago)
- Topics: clojure, logging, mdc, slf4j
- Language: Clojure
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# slf4j-mdc
Clojure utility for SLF4J logging system's MDC (Mapped Diagnostic Context).
[](https://clojars.org/com.github.strojure/slf4j-mdc)
## Design goals
* Helper functionality to work with MDC.
## Usage
```clojure
(ns readme.usage
(:require [clojure.tools.logging :as log]
[strojure.slf4j-mdc.core :as mdc]))
(defn- update-user
[user-id, data]
(with-open [_ (mdc/put-closeable "user-id" (str user-id))
_ (mdc/put-closeable "empty" nil)]
(log/debug "Update user" data)))
(comment
(update-user 100 {:name "Name"})
;; DEBUG readme.usage [ user-id=100 ]
;; - Update user {:name Name}
(with-open [_ (mdc/put-closeable "request-id" "64024bf5-862a-4e9f-a827-b924fc04f6d8")]
(update-user 100 {:name "Name"}))
;; DEBUG readme.usage [ request-id=64024bf5-862a-4e9f-a827-b924fc04f6d8, user-id=100 ]
;; - Update user {:name Name}
)
```