elastic / ecs-logging-java

https://www.elastic.co/guide/en/ecs-logging/java/current/intro.html
Apache License 2.0
139 stars 74 forks source link

New appender in "logback-ecs-encoder" #137

Closed ipalbeniz closed 2 years ago

ipalbeniz commented 2 years ago

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 :smile:

eyalkoren commented 2 years ago

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

ipalbeniz commented 2 years ago

New appender included in https://github.com/elastic/ecs-logging-java/pull/138

ipalbeniz commented 2 years ago

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

eyalkoren commented 2 years ago

Done - https://github.com/elastic/ecs-logging-java/releases/tag/v1.2.0