tkowalcz / tjahzi

Java clients, log4j2 and logback appenders for Grafana Loki
MIT License
106 stars 18 forks source link

Is it possible to use this appender with a json layout? #109

Open SimonBalling opened 1 year ago

SimonBalling commented 1 year ago

Like the title sais, I want to send my log file to loki but in a json format.

As far as I am aware, This is the way to do it normally:

        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
            <layout class="ch.qos.logback.contrib.json.classic.JsonLayout">
                <jsonFormatter class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter"/>
                <timestampFormat>yyyy-MM-dd HH:mm:ss.SSS</timestampFormat>
                <appendLineSeparator>true</appendLineSeparator>
            </layout>
        </appender>

Is it possible to do this using this appender? I tried everything I could think of but I think that this way doesnt work because this appender uses a "PatternLayout"

tkowalcz commented 1 year ago

You are right. Thanks for doing due diligence. I had to read more about how Logback encoders and layouts work. I think I know how to fix the appender. It'll take few days before I have time to release new version.

Urganot commented 1 year ago

No problem :) Fyi: I found a workaround by defining my own converter. Maybe thats one way to implement it

SimonBalling commented 1 year ago

Oops. Wrong account