Skip to content

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

@ipalbeniz

Description

@ipalbeniz

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 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions