Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aaabramov/glogging

Logback layout for Google Structured logging
https://github.com/aaabramov/glogging

Last synced: 13 days ago
JSON representation

Logback layout for Google Structured logging

Awesome Lists containing this project

README

        

# Logback layout for Google Structured logging

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.aaabramov/glogging/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.aaabramov/glogging) ![Build](https://github.com/aaabramov/glogging/actions/workflows/maven.yml/badge.svg)

---

[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://stand-with-ukraine.pp.ua)

---

## Why?

- Google indexes logs - easies and faster to filter logs.
See [Using the Logs Explorer](https://cloud.google.com/logging/docs/view/logs-viewer-interface)
- Aggregating logs by labels
- Log metrics
- Proper logging levels in the UI
- See [this StackOverflow](https://stackoverflow.com/q/44164730/5091346) question

See [structured logs](https://cloud.google.com/logging/docs/structured-logging).

## Getting started

Maven:

```xml


io.github.aaabramov
glogging-core
0.1.0


io.github.aaabramov
glogging-gson


0.1.0

```

Gradle (Groovy):

```groovy
implementation 'io.github.aaabramov:glogging-core:0.1.0'
implementation 'io.github.aaabramov:glogging-gson:0.1.0'
// OR
// implementation 'io.github.aaabramov:glogging-jackson:0.1.0'
```

Gradle (Kotlin):

```kotlin
implementation("io.github.aaabramov:glogging-core:0.1.0")
implementation("io.github.aaabramov:glogging-gson:0.1.0")
// OR
// implementation("io.github.aaabramov:glogging-jackson:0.1.0")
```

Sbt:

```sbt
libraryDependencies ++= Seq(
"io.github.aaabramov" % "glogging-core",
"io.github.aaabramov" % "glogging-gson"
// OR
// "io.github.aaabramov" % "glogging-jackson"
).map(_ % "0.1.0")
```

## Configuration example:

```xml




io.github.aaabramov.glogging.JacksonEncoder



true


com.yourcompany



%message %xException{10}







```

## Example output:

```
{"timestamp":{"seconds":1629642099,"nanos":659000000},"severity":"DEBUG","message":"debug","labels":{"io.github.aaabramov/name":"Andrii","io.github.aaabramov/loggerName":"io.github.aaabramov.glogging.App"}}
{"timestamp":{"seconds":1629642099,"nanos":659000000},"severity":"INFO","message":"info","labels":{"io.github.aaabramov/name":"Andrii","io.github.aaabramov/loggerName":"io.github.aaabramov.glogging.App"}}
{"timestamp":{"seconds":1629642099,"nanos":659000000},"severity":"WARN","message":"warn","labels":{"io.github.aaabramov/name":"Andrii","io.github.aaabramov/loggerName":"io.github.aaabramov.glogging.App"}}
{"timestamp":{"seconds":1629642099,"nanos":661000000},"severity":"ERROR","message":"error java.lang.RuntimeException: BOOM\n\tat io.github.aaabramov.glogging.App.main(App.java:22)","labels":{"io.github.aaabramov/name":"Andrii","io.github.aaabramov/loggerName":"io.github.aaabramov.glogging.App"}}
{"timestamp":{"seconds":1629642102,"nanos":661000000},"severity":"DEBUG","message":"debug","labels":{"io.github.aaabramov/name":"Andrii","io.github.aaabramov/loggerName":"io.github.aaabramov.glogging.App"}}
{"timestamp":{"seconds":1629642102,"nanos":661000000},"severity":"INFO","message":"info","labels":{"io.github.aaabramov/name":"Andrii","io.github.aaabramov/loggerName":"io.github.aaabramov.glogging.App"}}
{"timestamp":{"seconds":1629642102,"nanos":661000000},"severity":"WARN","message":"warn","labels":{"io.github.aaabramov/name":"Andrii","io.github.aaabramov/loggerName":"io.github.aaabramov.glogging.App"}}
{"timestamp":{"seconds":1629642102,"nanos":661000000},"severity":"ERROR","message":"error","labels":{"io.github.aaabramov/name":"Andrii","io.github.aaabramov/loggerName":"io.github.aaabramov.glogging.App"}}
```

## Releasing

```bash
mvn versions:set -DnewVersion=X.Y.Z
mvn versions:commit
mvn clean javadoc:jar source:jar verify gpg:sign deploy
# Close & Release here https://s01.oss.sonatype.org/#stagingRepositories
```