title: Logback to Elasticsearch through yaml or properties
body: <p>I have many spring based microservice project where I used Logback to Elasticsearch for saving all logs to Elastic search index. I have configured using xml based on some tutorials I got. The configuration is based on xml like as shown below. Instead of xml how can we configure Logback to Elasticsearch using yaml or key value property files.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
      &lt;springProperty scope="context" name="microserviceName"
          source="spring.application.name" /&gt;
      &lt;springProperty scope="context" name="profile"
          source="spring.profiles.active" /&gt;
      &lt;springProperty scope="context" name="myESHost"
          source="logging.esHost" /&gt;
      &lt;springProperty scope="context" name="myESPort"
          source="logging.esPort" /&gt;
      &lt;springProperty scope="context" name="myESLoggingLevel"
          source="logging.esLoggingLevel" /&gt;  
      &lt;springProperty scope="context" name="consoleLoggingLevel"
          source="logging.consoleLoggingLevel" /&gt; 
  
      &lt;appender name="ELASTIC" class="com.internetitem.logback.elasticsearch.ElasticsearchAppender"&gt;
          &lt;url&gt;http://${myESHost}:${myESPort}/_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;false&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="com.internetitem.logback.elasticsearch.config.BasicAuthentication" /&gt; &lt;!-- optional --&gt;
          &lt;properties&gt;
              &lt;property&gt;
                  &lt;name&gt;host&lt;/name&gt;
                  &lt;value&gt;${HOSTNAME}&lt;/value&gt;
                  &lt;allowEmpty&gt;false&lt;/allowEmpty&gt;
              &lt;/property&gt;
              &lt;property&gt;
                  &lt;name&gt;severity&lt;/name&gt;
                  &lt;value&gt;%level&lt;/value&gt;
              &lt;/property&gt;
              &lt;property&gt;
                  &lt;name&gt;thread&lt;/name&gt;
                  &lt;value&gt;%thread&lt;/value&gt;
              &lt;/property&gt;
              &lt;property&gt;
                  &lt;name&gt;stacktrace&lt;/name&gt;
                  &lt;value&gt;%ex&lt;/value&gt;
              &lt;/property&gt;
              &lt;property&gt;
                  &lt;name&gt;logger&lt;/name&gt;
                  &lt;value&gt;%logger&lt;/value&gt;
              &lt;/property&gt;
          &lt;/properties&gt;
          &lt;headers&gt;
              &lt;header&gt;
                  &lt;name&gt;Content-Type&lt;/name&gt;
                  &lt;value&gt;text/plain&lt;/value&gt;
              &lt;/header&gt;
          &lt;/headers&gt;
      &lt;/appender&gt;
  
      &lt;root level="info"&gt;
          &lt;appender-ref ref="FILELOGGER" /&gt;
          &lt;appender-ref ref="ELASTIC" /&gt;
      &lt;/root&gt;
  
      &lt;logger name="es-error-logger" level="INFO" additivity="false"&gt;
          &lt;appender-ref ref="FILELOGGER" /&gt;
      &lt;/logger&gt;
  
      &lt;logger name="es-logger" level="INFO" additivity="false"&gt;
          &lt;appender name="ES_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
              &lt;!-- ... --&gt;
              &lt;encoder&gt;
                  &lt;pattern&gt;%msg&lt;/pattern&gt; &lt;!-- This pattern is important, otherwise it won't be the raw Elasticsearch format anyomre --&gt;
              &lt;/encoder&gt;
          &lt;/appender&gt;
      &lt;/logger&gt;
  
  &lt;/configuration&gt;
  </code></pre>