Wildfly-Elasticsearch-REST-LogHandler

Elasticsearch log handler sends logs to elasticsearch cluster using REST API.

Configuration
1.Copy modules/org/wildfly to $WILDFLY_HOME/modules/system/layers/base/org.
2.Edit WildFly configuration file

  1. adding custom-handler for ElasticsearchCustomHandler:
<custom-handler name="ELASTICSEARCH" class="org.wildfly.elasticsearch.log.ElasticsearchCustomHandler" module="org.wildfly.elasticsearch.log">
  <formatter>
    <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
  </formatter>
  <properties>
    <property name="index" value="logs-%tY-%tm-%td"/>
    <property name="indexType" value="server"/>
    <property name="url" value=""/>
    <property name="checkRetryInterval" value="true"/>
    <property name="retryInterval" value="30000"/>
    <property name="connectTimeout" value="30000"/>
    <property name="readTimeout" value="30000"/>
    <property name="maxQueueSize" value="10485760"/>
    <property name="enabled" value="true"/>
  </properties>
</custom-handler>
  1. adding the ELASTICSEARCH handler to root-logger:
<root-logger>
  <level name="DEBUG"/>
  <handlers>
    <handler name="CONSOLE"/>
    <handler name="ELASTICSEARCH"/>
  </handlers>>
</root-logger>

Properties
index - Elasticsearch index to send WildFly logs;
indexType - URL Elasticsearch bulk API endpoint;
url - URL of Elasticsearch bulk API endpoint;
checkRetryInterval - if it is set to true and Elasticsearch host is available then the Elasticsearch handler repeat attempt to connect to the Elasticsearch host in the interval specified in the property retryInterval. If checkRetryInterval is set to false then the handler checks the Elasticsearch host when sending WildFly logs.
retryInterval - the interval between attempts of connecting to the Elasticsearch host (ms);
maxRetries - maximum of attempts to connect to the Elasticsearch host;
connectionTimeout - timeout of connection to the Elasticsearch host (ms);
The interval between attempts of connecting to the Elasticsearch host is set in the property retryInterval (ms). Maximum of attempts to connect to the Elasticsearch host is set in the property maxRetries. Timeout of connection to the Elasticsearch host is set in the property connectionTimeout (ms).
readTimeout - Elasticsearch read timeout (ms);
maxQueueSize - maximum size of log message buffer;
enabled - if it set to true then Wildfly logs are processed in the handler, otherwise sending Wildfly logs to Elasticsearch is disabled.