title: Log4j logging directly to elasticsearch server
body: <p>I'm a bit confused on how can I put my log entries directly to <code>elasticsearch</code> (not logstash). So far I found a few appenders (<code>log4j.appender.SocketAppender</code>, <code>log4j.appender.server</code> etc.) that allow to send logs to remote host and also <code>ConversionPattern</code> possibility that seems to allow us to convert logs to "elastic-friendly" format, but this approach looks freaky... or do I mistake? Is this the one way to send logs to <code>elastic</code>?</p>
  
  <p>So far I have a such config:</p>
  
  <pre><code>log4j.rootLogger=DEBUG, server
  log4j.appender.server=org.apache.log4j.net.SocketAppender
  log4j.appender.server.Port=9200
  log4j.appender.server.RemoteHost=localhost
  log4j.appender.server.ReconnectionDelay=10000
  log4j.appender.server.layout.ConversionPattern={"debug_level":"%p","debug_timestamp":"%d{ISO8601}","debug_thread":"%t","debug_file":"%F", "debug_line":"%L","debug_message":"%m"}%n
  </code></pre>
  
  <p>But I get an error:</p>
  
  <pre><code>log4j:WARN Detected problem with connection: java.net.SocketException: Broken pipe (Write failed)
  </code></pre>
  
  <p>I can't find any useful example so I can't understand what do I do wrong and how to fix it. Thanks.</p>