elastic/ecs-logging-java

New appender in "logback-ecs-encoder"

ipalbeniz opened this issue · 4 comments

Hi!

I'm using "logback-ecs-encoder" to write logs in ECS Json format into a file, using the appender available in "co/elastic/logging/logback/boot/ecs-file-appender.xml".

I think it would be great to have another appender to write the log in ECS Json format to the console because an increasing amount of people is reading the logs from console in kubernetes (https://www.elastic.co/guide/en/ecs-logging/java/1.x/setup.html#setup-step-3)

¿Would it be possible to have a new appender like "co/elastic/logging/logback/boot/ecs-console-appender.xml" inside "logback-ecs-encoder"?

The content could be similar to:

<?xml version="1.0" encoding="UTF-8"?>

<!--
ECS JSON console appender logback configuration provided for import, similar to the console-appender.xml included in Spring Boot
<include resource="co/elastic/logging/logback/boot/ecs-console-appender.xml" />
-->

<included>
    <springProperty name="SERVICE_NAME" source="spring.application.name"/>
    <appender name="ECS_JSON_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="co.elastic.logging.logback.EcsEncoder">
            <serviceName>${SERVICE_NAME:-spring-boot-application}</serviceName>
        </encoder>
    </appender>
</included>

If you see it reasonable I would be willing to send a pull request 😄

Sure, if you feel it would be useful to have this example as well - go ahead and add it. Thanks!

New appender included in #138

Hi @eyalkoren,
Do you know when will it be released?