title: Spring Boot logging to elasticsearch server using bulk endpoint
body: <p>I am new to Spring Boot / ELK and I'm probably missing something. Basically I have a Spring Boot APP and I want to submit the logs of the app to ElasticSearch so that I can see it in Kibana.
  I have created a ElasticSearch server via docker:</p>
  <pre><code>  elasticsearch:
      container_name: elasticsearch
      image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
      network_mode: bridge
      environment:
        - node.name=elasticsearch
        - cluster.name=es-docker-cluster
        - discovery.type=single-node
        - bootstrap.memory_lock=true
        - &quot;ES_JAVA_OPTS=-Xms512m -Xmx512m&quot;
      ports:
        - &quot;9200:9200&quot;
      ulimits:
        memlock:
          soft: -1
          hard: -1
      volumes:
        - data01:/usr/share/elasticsearch/data
  
    localstack:
      container_name: &quot;${LOCALSTACK_DOCKER_NAME-localstack_main}&quot;
      image: localstack/localstack
      network_mode: bridge
      ports:
        - &quot;4566:4566&quot;
        - &quot;4571:4571&quot;
      depends_on:
        - elasticsearch
      environment:
        - SERVICES=es
        - ELASTICSEARCH_BACKEND=http://elasticsearch:9200
        - DEBUG=${DEBUG- }
        - DATA_DIR=${DATA_DIR- }
        - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR- }
        - KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
        - DOCKER_HOST=unix:///var/run/docker.sock
        - HOST_TMP_FOLDER=${TMPDIR}
      volumes:
        - &quot;${TMPDIR:-/tmp/localstack}:/tmp/localstack&quot;
        - &quot;/var/run/docker.sock:/var/run/docker.sock&quot;
      links:
        - elasticsearch
  
  volumes:
    data01:
      driver: local
  </code></pre>
  <p>Running this docker compose generates me an ElasticSearch host <code>http://mylogs-2.us-east-1.es.localhost.localstack.cloud:4566/</code> and I created (PUT) an index my-index in this elastic.</p>
  <p>Then I'm trying to configure my app to point to the bulk [url property] endpoint using <code>logback-spring.xml</code> :</p>
  <pre><code>&lt;appender name=&quot;ELASTIC&quot; class=&quot;com.internetitem.logback.elasticsearch.ElasticsearchAppender&quot;&gt;
      &lt;url&gt;http://mylogs-2.us-east-1.es.localhost.localstack.cloud:4566/my-index/_bulk&lt;/url&gt;
      &lt;index&gt;logs-%date{yyyy-MM-dd}&lt;/index&gt;
      &lt;type&gt;tester&lt;/type&gt;
      &lt;loggerName&gt;es-logger&lt;/loggerName&gt; &lt;!-- optional --&gt;
      &lt;errorLoggerName&gt;es-error-logger&lt;/errorLoggerName&gt; &lt;!-- optional --&gt;
      &lt;connectTimeout&gt;30000&lt;/connectTimeout&gt; &lt;!-- optional (in ms, default 30000) --&gt;
      &lt;errorsToStderr&gt;false&lt;/errorsToStderr&gt; &lt;!-- optional (default false) --&gt;
      &lt;includeCallerData&gt;false&lt;/includeCallerData&gt; &lt;!-- optional (default false) --&gt;
      &lt;logsToStderr&gt;false&lt;/logsToStderr&gt; &lt;!-- optional (default false) --&gt;
      &lt;maxQueueSize&gt;104857600&lt;/maxQueueSize&gt; &lt;!-- optional (default 104857600) --&gt;
      &lt;maxRetries&gt;3&lt;/maxRetries&gt; &lt;!-- optional (default 3) --&gt;
      &lt;readTimeout&gt;30000&lt;/readTimeout&gt; &lt;!-- optional (in ms, default 30000) --&gt;
      &lt;sleepTime&gt;250&lt;/sleepTime&gt; &lt;!-- optional (in ms, default 250) --&gt;
      &lt;rawJsonMessage&gt;true&lt;/rawJsonMessage&gt; &lt;!-- optional (default false) --&gt;
      &lt;includeMdc&gt;false&lt;/includeMdc&gt; &lt;!-- optional (default false) --&gt;
      &lt;maxMessageSize&gt;100&lt;/maxMessageSize&gt; &lt;!-- optional (default -1 --&gt;
      &lt;authentication class=&quot;com.internetitem.logback.elasticsearch.config.BasicAuthentication&quot; /&gt; &lt;!-- optional --&gt;
      &lt;headers&gt;
        &lt;header&gt;
          &lt;name&gt;Content-Type&lt;/name&gt;
          &lt;value&gt;application/x-ndjson&lt;/value&gt;
        &lt;/header&gt;
      &lt;/headers&gt;
    &lt;/appender&gt;
  
  ... 
  
    &lt;logger name=&quot;es-logger&quot; level=&quot;INFO&quot; additivity=&quot;false&quot;&gt;
      &lt;appender-ref ref=&quot;STDOUT&quot; /&gt;
      &lt;appender-ref ref=&quot;ELASTIC&quot; /&gt;
    &lt;/logger&gt;
  
  </code></pre>
  <p>And I start Kibana with kibana.yml pointing to this elastic host. File looks like:</p>
  <p>elasticsearch.hosts: [&quot;http://mylogs-2.us-east-1.es.localhost.localstack.cloud:4566&quot;]</p>
  <p>However I cannot see the logs in Kibana when I start my spring boot app (and trigger the endpoint which uses a org.slf4j.Logger to log)</p>
  <p>NOTE: When I manually POST data to the bulk endpoint in Postman works fine</p>
  <p>POST <a href="http://mylogs-2.us-east-1.es.localhost.localstack.cloud:4566/my-index/_bulk" rel="nofollow noreferrer">http://mylogs-2.us-east-1.es.localhost.localstack.cloud:4566/my-index/_bulk</a>
  ´´´
  { &quot;index&quot;: {} }
  { &quot;name&quot;: &quot;Test33&quot;, &quot;data&quot;: &quot;This is my test data333&quot; }
  ´´´</p>
  <p>I tried looking online but I couldnt find a specific example on how to use this logback and bulk endpoint.
  What am I missing? Is it not the right way to post to bulk endpoint?</p>
  <p>Thanks for reading all this</p>