-
Notifications
You must be signed in to change notification settings - Fork 45
Home
Welcome to the logback-kafka wiki!
Kafka 0.7.1 upgrade Kafka 0.8.1.1
- pom.xml
� org.apache.kafka kafka_2.9.2 � 0.8.1.1 � org.scala-lang � scala-library � 2.9.2 �
2)logback-formatter.xml & logback.xml
The new attribute "broker" logback_topic localhost:2181 localhost:9092
-
Use of kafka version of the API to producer ..... @Override public void start() { if (this.formatter == null) { this.formatter = new MessageFormatter(); } super.start(); Properties props = new Properties(); props.put("zk.connect", this.zookeeperHost); props.put("metadata.broker.list", this.broker); props.put("serializer.class", "kafka.serializer.StringEncoder"); props.put("zk.connectiontimeout.ms","15000"); props.put("request.required.acks","1"); ProducerConfig config = new ProducerConfig(props); this.producer = new Producer<String, String>(config); }
@Override public void stop() { super.stop(); this.producer.close(); }
@Override protected void append(ILoggingEvent event) { try{ String payload = this.formatter.format(event); KeyedMessage<String, String> message = new KeyedMessage<String, String>(topic, payload); this.producer.send(message); }catch(Exception e){ e.printStackTrace(); } }
Also please advice .
thank you !