1

I am deploying my application to Azure kubernetes with Log monitoring. For readability issues with error logs I'd like to log to JSON instead of console lines. I've been using default logback configuration and now I am trying to change it just to change the format of logs.

logback-spring.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
        <appender name="jsonAppender" class="ch.qos.logback.core.ConsoleAppender">
            <layout class="ch.qos.logback.contrib.json.classic.JsonLayout">
                <jsonFormatter
                        class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
                    <prettyPrint>true</prettyPrint>
                </jsonFormatter>
                <timestampFormat>yyyy-MM-dd' 'HH:mm:ss.SSS</timestampFormat>
            </layout>
        </appender>

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

It works perfectly on local (also in Docker), however after deploy to AKS there is still old log format. Does anyone know what is causing this?

EDIT The main problem was in packaging - logback-spring.xml was not part of my production jar. So now I have JSON logs in my Log Analytics but stacktraces are still on separate lines outside of JSON and I cannot get them into the object.

KHanusova
  • 187
  • 2
  • 10

1 Answers1

0

You can use some of the open source plugin that can help you to import and search your Kubernetes logging, object, and metrics data and format data also.

Splunk Connect for Kubernetes supports importing and searching your container logs on the AKS.

There is one more ie Collectord.. Collectord provides flexible and powerful tools for transforming logs.. Collectord forwards container logs, host logs and can discover logs written by the containerized applications.

RahulKumarShaw
  • 4,192
  • 2
  • 5
  • 11