Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for logging in JSON format #502

Closed
nscuro opened this issue Jul 10, 2023 · 0 comments · Fixed by #503
Closed

Add support for logging in JSON format #502

nscuro opened this issue Jul 10, 2023 · 0 comments · Fixed by #503

Comments

@nscuro
Copy link
Collaborator

nscuro commented Jul 10, 2023

To make parsing in centralized logging solutions like ELK or Splunk easier, applications built on Alpine should be able to emit their logs in JSON format, instead of raw text.

The logback configuration file to use can be overridden at runtime, via -DlogbackConfigurationFile=..., so users can already adjust the logging behavior to their choosing. However, logback does not have built-in JSON support, so an additional extension is required.

nscuro added a commit to nscuro/Alpine that referenced this issue Jul 10, 2023
This makes `logstash-logback-encoder` (and its required dependencies) available in the executable WAR's classpath, which enables usage of `LogstashEncoder` in the logback configuration file.

A minimal sample `logback.xml` using the encoder looks like this:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
    <appender name="JSON_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="net.logstash.logback.encoder.LogstashEncoder" />
    </appender>

    <root level="INFO">
        <appender-ref ref="JSON_STDOUT" />
    </root>
</configuration>
```

Closes stevespringett#502

Signed-off-by: nscuro <nscuro@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant