Giter Site home page Giter Site logo

avaje-logback-encoder's Introduction

Build License Maven Central : avaje-record-builder Discord

avaje-logback-encoder

logback encoder that uses avaje-jsonb to log events as json

Usage

Add the encoder to your appender

<appender name="app" class="your.appender.class">
    <encoder class="io.avaje.logback.encoder.JsonbEncoder">
        <-- configuration -->
    </encoder>
</appender>

JPMS Use

To ensure jlink correctly determines the runtime modules required, add the following to your module-info.java:

module my.module {
  requires io.avaje.logback.encoder;  
}

Global Custom Fields

Add custom fields that will appear in every LoggingEvent like this :

<encoder class="io.avaje.logback.encoder.JsonbEncoder">
    <customFields>{"appname":"myWebservice","roles":["customerorder","auth"],"buildinfo":{"version":"Version 0.1.0-SNAPSHOT","lastcommit":"75473700d5befa953c45f630c6d9105413c16fe1"}}</customFields>
</encoder>

Customizing Timestamp

By default, timestamps are written as string values in the format specified by DateTimeFormatter.ISO_OFFSET_DATE_TIME (e.g. 2019-11-03T10:15:30.123+01:00), in the default TimeZone of the host Java platform.

You can change the pattern like this:

<encoder class="io.avaje.logback.encoder.JsonbEncoder">
    <timestampPattern>yyyy-MM-dd'T'HH:mm:ss.SSS</timestampPattern>
</encoder>

The value of the timestampPattern can be any of the following:

  • constant - (e.g. ISO_OFFSET_DATE_TIME) timestamp written using the given DateTimeFormatter constant
  • any other value - (e.g. yyyy-MM-dd'T'HH:mm:ss.SSS) timestamp written using a DateTimeFormatter created from the given pattern

The formatter uses the default TimeZone of the host Java platform by default. You can change it like this:

<encoder class="io.avaje.logback.encoder.JsonbEncoder">
    <timeZone>UTC</timeZone>
</encoder>

The value of the timeZone element can be any string accepted by java's TimeZone.getTimeZone(String id) method. For example America/Los_Angeles, GMT+10 or UTC. Use the special value [DEFAULT] to use the default TimeZone of the system.

avaje-logback-encoder's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar sentryman avatar rbygrave avatar rob-bygrave avatar

Stargazers

Ashley avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

avaje-logback-encoder's Issues

Support custom fields

Logstash has the ability to accept custom fields from the XML, let's support that too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.