Skip to content

tsyma/logstash-logback-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

~# whitelabels-logstash-logback

logstash-logback-http provide HttpAppender to sending log messages from logback to logstash via http or https

Building

mvn clean install

Using

pom.xml

<dependency>
  <groupId>de.idealo.whitelabels</groupId>
  <artifactId>logstash-logback-http</artifactId>
  <version>1.2</version>
</dependency>

Configuring HttpAppender

resources/logback-spring.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>

  <springProperty scope="context" name="projectName" source="whitelabels.project-name"
    defaultValue="whitelabels-indexation"/>
  <springProperty scope="context" name="stage" source="stage" defaultValue="local"/>

  <appender name="LOCAL-CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} %5level %logger{0} [%t] [%mdc] - %msg%n</pattern>
    </encoder>
  </appender>

  <appender name="LOGSTASH"
    class="net.logstash.logback.appender.LoggingEventAsyncDisruptorAppender">
    <ringBufferSize>8192</ringBufferSize>
    <appender class="de.idealo.whitelabels.logback.HttpAppender">
      <httpClient class="de.idealo.whitelabels.logback.HttpClient">
        <destination>https://JOUR.LOGSTASH.URL</destination>
      </httpClient>
      <encoder class="net.logstash.logback.encoder.LogstashEncoder">
        <fieldNames>
          <timestamp>timestamp</timestamp>
        </fieldNames>
      </encoder>
    </appender>
  </appender>

  <springProfile name="local">
    <root level="info">
      <appender-ref ref="LOGSTASH"/>
      <appender-ref ref="LOCAL-CONSOLE"/>
    </root>
  </springProfile>

</configuration>

Documentation: