Skip to content

Commit

Permalink
Merge pull request #65 from devatherock/json-logs
Browse files Browse the repository at this point in the history
feat: Added support for JSON logs
  • Loading branch information
devatherock authored Apr 2, 2021
2 parents c860dad + 5b258a5 commit e792c6f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# Changelog

## [Unreleased]
### Added
- Support for JSON logs

### Changed
- Corrected docker image for release job in build pipeline
- chore: Upgraded micronaut from 2.1.0 to 2.3.1
- chore: Upgraded micronaut from 2.1.0 to 2.4.2
- fix: Set log level of `NettyHttpServer` to `TRACE` to show logs in micronaut 2.3.x

## [0.2.1] - 2020-11-20
### Changed
- Corrected docker image for release job in build pipeline

## [0.2.0] - 2020-11-20
### Added
- Initial version that generates docker pulls, image size and layers badges
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ docker run --rm \
- Set the environment variable `LOGGING_LEVEL_IO_GITHUB_DEVATHEROCK` to `DEBUG` to enable debug logs only in custom code
- For fine-grained logging control, supply a custom [logback.xml](http://logback.qos.ch/manual/configuration.html) file
and set the environment variable `JAVA_OPTS` to `-Dlogback.configurationFile=/path/to/custom/logback.xml`

### JSON logs

To output logs as JSON, set the environment variable `JAVA_OPTS` to `-Dlogback.configurationFile=logback-json.xml`. Refer
[logstash-logback-encoder](https://github.com/logstash/logstash-logback-encoder) documentation to customize the field names and
formats in the log
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
id 'com.github.kt3k.coveralls' version '2.11.0'
}

version "0.2.0"
version "0.3.0"
group "io.github.devatherock"

repositories {
Expand Down Expand Up @@ -46,6 +46,8 @@ dependencies {
implementation "io.micronaut:micronaut-http-client"
implementation "io.micronaut.cache:micronaut-cache-core"
implementation "io.micronaut.cache:micronaut-cache-caffeine"

implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '6.6'

runtimeOnly "ch.qos.logback:logback-classic:1.2.3"
testAnnotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")
Expand Down
14 changes: 14 additions & 0 deletions src/main/resources/logback-json.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<configuration>
<variable name="LOGGING_LEVEL_ROOT" value="${LOGGING_LEVEL_ROOT:-INFO}" />
<variable name="LOGGING_LEVEL_IO_GITHUB_DEVATHEROCK" value="${LOGGING_LEVEL_IO_GITHUB_DEVATHEROCK:-INFO}" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>

<root level="${LOGGING_LEVEL_ROOT}">
<appender-ref ref="STDOUT" />
</root>
<logger name="io.github.devatherock" level="${LOGGING_LEVEL_IO_GITHUB_DEVATHEROCK}" />
<logger name="io.micronaut.http.server.netty.NettyHttpServer" level="TRACE" />
</configuration>

0 comments on commit e792c6f

Please sign in to comment.