项目作者: lagenorhynque

项目描述 :
Duct module for Cambium, a library for structured (JSON) logging in Clojure
高级语言: Clojure
项目地址: git://github.com/lagenorhynque/duct.module.cambium.git
创建时间: 2019-11-04T10:50:20Z
项目社区:https://github.com/lagenorhynque/duct.module.cambium

开源协议:Eclipse Public License 2.0

下载


duct.module.cambium

Clojars Project
Circle CI
codecov

A Duct module that adds logging to a configuration, using Cambium. This is an alternative to duct/module.logging.

Installation

To install, add the following to your project :dependencies:

  1. [duct.module.cambium "1.3.1"]

Usage

To add this module to your configuration, add a reference to :duct.module/cambium:

  1. {:duct.profile/base
  2. {:duct.core/project-ns some-api
  3. :duct.profile/dev #duct/include "dev"
  4. :duct.profile/local #duct/include "local"
  5. :duct.profile/prod {}
  6. :duct.module/cambium {}}
  • :duct.module/cambium can have one option:
    • :top-level-field: top-level field name for nested data of MDC map (default: :option)

And add logback.xml (or logback-test.xml) as below to the resource path.

  1. <configuration>
  2. <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  3. <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
  4. <layout class="cambium.logback.json.FlatJsonLayout">
  5. <jsonFormatter class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
  6. <!-- prettyPrint is probably ok in dev, but usually not ideal in production: -->
  7. <prettyPrint>true</prettyPrint>
  8. </jsonFormatter>
  9. <!-- <context>api</context> -->
  10. <timestampFormat>yyyy-MM-dd'T'HH:mm:ss.SSS'Z'</timestampFormat>
  11. <timestampFormatTimezoneId>UTC</timestampFormatTimezoneId>
  12. <appendLineSeparator>true</appendLineSeparator>
  13. </layout>
  14. </encoder>
  15. </appender>
  16. <root level="debug">
  17. <appender-ref ref="STDOUT" ></appender-ref>
  18. </root>
  19. </configuration>

Examples

License

Copyright © 2019 Kent OHASHI

This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the Eclipse
Public License, v. 2.0 are satisfied: GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at your
option) any later version, with the GNU Classpath Exception which is available
at https://www.gnu.org/software/classpath/license.html.