简体   繁体   中英

Logback color coding not working in Grafana Loki logs

I have a spring boot application which is containarized. Following is logback.xml for my spring boot application,

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property name="LOG_PATH" value="logs" />
    <appender name="STDOUT"
        class="ch.qos.logback.core.ConsoleAppender">
        <encoder>

            <pattern>

                %d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %highlight(%-5level)
                %cyan(%logger{36}) - %msg %n
            </pattern>
        </encoder>
    </appender>
    <root level="INFO">
        <appender-ref ref="STDOUT" />
    </root>
</configuration>

I am pushing logs from this container to fluentd and further to loki. But when I see logs in grafana loki I am getting following junk characters in my logs.

在此处输入图像描述 Also color coding for log levels is not working properly.

What you're seeing are ANSI control sequences. They are used for color coding on the console. As you noticed, Graphana doesn't support ANSI colors as it has other ways of separating different log levels. To remove the extra characters in Graphana, your only option is to turn of color coding in your log. If you want or need color coding in your local logs, you'll have to configure two different appenders, one for local logs (with color coding) and one to go to Graphana (without color coding).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM