Skip to content

lagenorhynque/duct.module.cambium

Repository files navigation

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:

[duct.module.cambium "1.3.1"]

Usage

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

{:duct.profile/base
 {:duct.core/project-ns some-api

 :duct.profile/dev   #duct/include "dev"
 :duct.profile/local #duct/include "local"
 :duct.profile/prod  {}

 :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.

<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
      <layout class="cambium.logback.json.FlatJsonLayout">
        <jsonFormatter class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
          <!-- prettyPrint is probably ok in dev, but usually not ideal in production: -->
          <prettyPrint>true</prettyPrint>
        </jsonFormatter>
        <!-- <context>api</context> -->
        <timestampFormat>yyyy-MM-dd'T'HH:mm:ss.SSS'Z'</timestampFormat>
        <timestampFormatTimezoneId>UTC</timestampFormatTimezoneId>
        <appendLineSeparator>true</appendLineSeparator>
      </layout>
    </encoder>
  </appender>
  <root level="debug">
    <appender-ref ref="STDOUT" />
  </root>
</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.

About

Duct module for Cambium, a library for structured (JSON) logging in Clojure

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published