Spring Boot Logging JSON

Enables JSON logging in Spring Boot applications

Лицензия

Лицензия

Категории

Категории

Spring Boot Контейнер Микросервисы JSON Данные Logging Библиотеки уровня приложения
Группа

Группа

io.github.goetschalckx
Идентификатор

Идентификатор

spring-boot-logging-json
Последняя версия

Последняя версия

0.1.1
Дата

Дата

Тип

Тип

pom.sha512
Описание

Описание

Spring Boot Logging JSON
Enables JSON logging in Spring Boot applications
Ссылка на сайт

Ссылка на сайт

https://github.com/goetschalckx/spring-boot-logging-json
Система контроля версий

Система контроля версий

https://github.com/goetschalckx/spring-boot-logging-json

Скачать spring-boot-logging-json

Зависимости

runtime (2)

Идентификатор библиотеки Тип Версия
net.logstash.logback : logstash-logback-encoder jar 6.3
ch.qos.logback : logback-classic jar 1.2.0

Модули Проекта

Данный проект не имеет модулей.

Build Status License

Coverage Codacy Codacy Coverage CodeFactor Vulnerabilities

Release Snapshot

spring-boot-logging-json

by Eric Goetschalckx

json structured JSON log support for Spring Boot applications.

This capability works best in environments using log aggregation tools like Stackdriver or ELK.

When enabled, each log event emitted is a minified JSON object containing the log message and other metadata.

Unlocks more potential from the Logstash Logback JSON encoder.

Having metadata in discrete JSON fields allows for advanced queries and visualizations in log aggregation UIs.

Uses high-performance LMAX Async Disruptor console appender.

Simple Sample Log Statement

{
  "log" : "c.g.s.log.json.TestApplication",
  "lvl" : "INFO",
  "thread" : "main",
  "msg" : "log examples {logstash.argument=example}",
  "ts" : "2019-11-13T01:24:51.200+00:00",
  "HOSTNAME" : "dev",
  "logstash.argument" : "example",
  "logstash.marker" : {
    "json" : "example"
  },
  "tags" : [ "slf4j.marker" ],
  "mdc" : "example"
}

Top-level JSON fields can be added using:

Minimum Requirements

Requires

  • spring-boot v1.4.0.RELEASE+
  • logstash-logback-encoder v6.3+

Spring Profiles

Use the following Spring profile(s) to enable the various logging output options.

  • default or log-dev
    • "Standard" Spring logging, colorized, pretty-printed, etc...
    • No support for custom fields.
  • log-json
    • json structured logs to the console.
    • Supports custom JSON fields.
    • Intended for containerized deployments.

Profiles Drawback

The problem with this approach is that if you already use a custom Spring Profile besides default, you will get no logs, which is less than ideal.

Configuration

The following configuration properties are available for managing logging settings:

# Logging settings 
logging:
  
  # Newline-delimited JSON Logging Settings
  json:
      
    # Enable JSON pretty-print
    # Optional (default is false)
    pretty-print: false
io.github.goetschalckx

Goetschalckx

Версии библиотеки

Версия
0.1.1
0.1.0