logfellow / logstash-logback-encoder

Logback JSON encoder and appenders
Apache License 2.0
2.44k stars 407 forks source link

Have logstash-logback-encoder send logs directly to elasticsearch backend #994

Open patpatpat123 opened 11 months ago

patpatpat123 commented 11 months ago

Is your feature request related to a problem? Please describe. This project is amazing. With simple configuration, like this one below, one can very easily forward logs to logstash, and have logstash forward the logs to elasticsearch.

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

    <springProperty scope="context" name="name" source="spring.application.name"/>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss} ${PID} %-5level --- [%thread] [${name},%X{traceId:-},%X{spanId:-}] %logger{36} : %msg%n
            </pattern>
        </encoder>
    </appender>

    <appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
        <encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
        <destination>mylogstash:5555</destination>
    </appender>

    <root level="INFO">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="LOGSTASH"/>
    </root>

</configuration>

Unfortunately, this requires to spin up and maintain an entire logstash instance, just for the sake of forwarding those logs.

Describe the solution you'd like

it would be great if this project can send to elasticsearch directly, something like

    <appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
        <encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
        <destination>myelasticsearch:9092/thelogindex</destination>
    </appender>

This would make this project even more awesome

Thank you for your consideration