I'm trying to use Logstash to index my log files created by log4j. I'm using the following versions:
- Logstash: 2.1.1
- ES: 2.1.0
- log4j: 1.2.17
I followed the recommendation found at http://stackoverflow.com/a/26227002 and use the SocketAppender in log4j configuration (and there are many more questions/articles on the net recommending the log4j input in Logstash and the SocketAppender in log4j)
The SocketAppender is defined as following:
<appender name="socket" class="org.apache.log4j.net.SocketAppender">
<param name="RemoteHost" value="localhost" />
<param name="Port" value="4560" />
<param name="LocationInfo" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%-25c] %m%n" />
</layout>
</appender>
I tried with the PatternLayout as described here https://www.elastic.co/blog/logging-elasticsearch-events-with-logstash-and-elasticsearch (although the pattern will be ignored according to http://stackoverflow.com/questions/11270504/how-to-use-pattern-layout-with-socketappender )
My pipe is defined as following:
input {
log4j {
mode => server
host => "0.0.0.0"
port => "4560"
type => "ex"
}
}
output {
stdout { codec => rubydebug }
elasticsearch { index => exlogs }
}
The events are indexed, and the output on stdout looks like the following:
{
"message" => "dummy error",
"@version" => "1",
"@timestamp" => "2015-12-15T09:00:43.978Z",
"timestamp" => 1450170043978,
"path" => "com.ex.monitoring.jmxclient.JmxReader",
"priority" => "ERROR",
"logger_name" => "com.ex.monitoring.jmxclient.JmxReader",
"thread" => "hugo",
"class" => "?",
"file" => "?:?",
"method" => "?",
"host" => "127.0.0.1:51808",
"type" => "ex"
}
I'm wondering why "class", "file", "method" are empty all the time? Am I doing anything wrong?