luminus-framework/log4j-edn-config

Name: log4j-edn-config

Owner: luminus-framework

Description: EDN configuration plugin for log4j

Created: 2016-07-06 13:47:39.0

Updated: 2018-04-18 13:40:22.0

Pushed: 2016-07-10 22:21:50.0

Homepage: null

Size: 18

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

log4j-edn-config

A Clojure library designed to provide EDN configuration support for log4j2

Usage

Clojars Project

warning Log4j has a bug that makes plugins incompatible with compatible uberjars. Log4j generates a plugin dat file, and only a single file can be present on the classpath, when multiple ones are present, then you'll end up with unexpected behaviors. Maven provides a plugin for handling the issue, however there's no way to do that via Leiningen at the moment.

Include the dependency in the project, log4j will pick it and allow using .edn files for configuraiton. The logging configruation must be present under the :logger key in the EDN file, e.g:

gger
onfiguration
name "DefaultConfig"
ThresholdFilter {:level "debug"}
appenders
:appender
[{:type "Console"
  :name "Console"
  :target "SYSTEM_OUT"
  :PatternLayout {:pattern "[%d][%p][%c] %m%n"}}
 {:type "RollingFile"
  :name "File"
  :fileName "./log/myapp.log"
  :filePattern "./log/myapp-%d{MM-dd-yyyy}-%i.log.gz"
  :PatternLayout {:pattern "[%d][%p][%c] %m%n"}
  :DefaultRolloverStrategy {:max "10"}
  :Policies
  {:SizeBasedTriggeringPolicy {:size "10 MB"}}}]}
loggers {:logger
         [{:name "org.xnio.nio"
           :level "warn"}]
         :root {:level "info"
                :AppenderRef
                [{:ref "Console"}
                 {:ref "File"}]}}}}}

The EDN under the :logger key is converted to JSON and follows log4j JSON configuration format. See the official log4j documentation on configuring JSON logging for details.

License

Copyright © 2016 Dmitri Sotnikov

Distributed under the Apache License 2.0


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.