https://github.com/lambdaisland/log4j2
Log4j2 wrapper for Clojure, drop in replacement for pedestal.log
https://github.com/lambdaisland/log4j2
Last synced: 2 months ago
JSON representation
Log4j2 wrapper for Clojure, drop in replacement for pedestal.log
- Host: GitHub
- URL: https://github.com/lambdaisland/log4j2
- Owner: lambdaisland
- License: mpl-2.0
- Created: 2025-08-29T12:22:00.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-08-30T07:02:07.000Z (4 months ago)
- Last Synced: 2025-10-14T06:44:53.480Z (2 months ago)
- Language: Clojure
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# log4j2
[](https://cljdoc.org/d/com.lambdaisland/log4j2) [](https://clojars.org/com.lambdaisland/log4j2)
Log4j2 wrapper for Clojure
## Features
## Installation
To use the latest release, add the following to your `deps.edn` ([Clojure CLI](https://clojure.org/guides/deps_and_cli))
```
com.lambdaisland/log4j2 {:mvn/version "0.2.6"}
```
or add the following to your `project.clj` ([Leiningen](https://leiningen.org/))
```
[com.lambdaisland/log4j2 "0.2.6"]
```
## Rationale
After many years of Slf4j and Logback, we are starting to shift to Log4j2 for
new projects. This micro-library contains a namespace which mimics pedestal.log,
and thus can act as a drop-in replacement.
## Usage
```
(ns my.ns
(:require
[lambdaisland.log4j2 :as log]))
(log/debug :db/preparing {:query query})
(log/info :application/starting {:port 1234})
(log/warn :config/missing-value {:key k} :message "Configuration value not found, using nil")
(log/error :api-call/failed {:req req} :exception e)
```
All calls have the same signature, an arbitrary sequence of keys and values.
These become key-values in a Log4j2 `MapMessage`, and can be logged e.g. to JSON
and fed into structured logging solutions.
A few keys have a special meaning
- `:exception` for throwables
- `:message` for a human readable message
These will be passed on to Log4j2 in the appropriate fields.
## Lambda Island Open Source
Thank you! This project is made possible thanks to our generous backers. [Become a
backer on OpenCollective](https://opencollective.com/lambda-island) so that we
can continue to make log4j2 better.
log4j2 is part of a growing collection of quality Clojure libraries created and maintained
by the fine folks at [Gaiwan](https://gaiwan.co).
Pay it forward by [becoming a backer on our OpenCollective](http://opencollective.com/lambda-island),
so that we continue to enjoy a thriving Clojure ecosystem.
You can find an overview of all our different projects at [lambdaisland/open-source](https://github.com/lambdaisland/open-source).
## Contributing
We warmly welcome patches to log4j2. Please keep in mind the following:
- adhere to the [LambdaIsland Clojure Style Guide](https://nextjournal.com/lambdaisland/clojure-style-guide)
- write patches that solve a problem
- start by stating the problem, then supply a minimal solution `*`
- by contributing you agree to license your contributions as MPL 2.0
- don't break the contract with downstream consumers `**`
- don't break the tests
We would very much appreciate it if you also
- update the CHANGELOG and README
- add tests for new functionality
We recommend opening an issue first, before opening a pull request. That way we
can make sure we agree what the problem is, and discuss how best to solve it.
This is especially true if you add new dependencies, or significantly increase
the API surface. In cases like these we need to decide if these changes are in
line with the project's goals.
`*` This goes for features too, a feature needs to solve a problem. State the problem it solves first, only then move on to solving it.
`**` Projects that have a version that starts with `0.` may still see breaking changes, although we also consider the level of community adoption. The more widespread a project is, the less likely we're willing to introduce breakage. See [LambdaIsland-flavored Versioning](https://github.com/lambdaisland/open-source#lambdaisland-flavored-versioning) for more info.
## License
Copyright © 2025 Arne Brasseur and Contributors
Licensed under the term of the Mozilla Public License 2.0, see LICENSE.
