Skip to content

Instantly share code, notes, and snippets.

@bringhurst
Created August 6, 2015 16:53
Show Gist options
  • Save bringhurst/c39fffe712f42c390c5b to your computer and use it in GitHub Desktop.
Save bringhurst/c39fffe712f42c390c5b to your computer and use it in GitHub Desktop.
An example of using the KafkaLog4jAppender with the JSONEventLayoutV1 for logstash/elasticsearch
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
<log4j:configuration>
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
</layout>
</appender>
<appender name="KAFKA" class="kafka.producer.KafkaLog4jAppender">
<layout class="net.logstash.log4j.JSONEventLayoutV1" >
<param name="UserFields" value="process-identifier:yarn-xxx-samza,process-type:nodemanager" />
</layout>
<param name="BrokerList" value="kafka-broker-a10:10251"/>
<param name="Topic" value="__samza_logging_nodemanager-yarn-xxx-samza"/>
<param name="ProducerType" value="async"/>
<param name="SerializerClass" value="AppenderStringEncoder"/>
</appender>
<root>
<priority value="info"></priority>
<appender-ref ref="stdout"/>
<appender-ref ref="KAFKA"/>
</root>
</log4j:configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment