Add support to propagate ONOS log to Kafka with KafkaAppender in log4j2
- new OSGi Bundle to define extra imports for log4j2
- update OSGiWrapper to support fragment-host tag + bugfix
- add kafka-clients to onos-dependencies package
- add example of how to propagate log to Kafka via KafkaAppender
- bugfix to org.ops4j.pax.logging.cfg
Change-Id: I89992936101a48c6452082bf23c7133c20aa0b48
diff --git a/tools/package/etc/org.ops4j.pax.logging.cfg b/tools/package/etc/org.ops4j.pax.logging.cfg
index 036447d..c771aa9 100644
--- a/tools/package/etc/org.ops4j.pax.logging.cfg
+++ b/tools/package/etc/org.ops4j.pax.logging.cfg
@@ -36,13 +36,12 @@
#log4j2.rootLogger.type = asyncRoot
#log4j2.rootLogger.includeLocation = false
log4j2.rootLogger.appenderRef.RollingFile.ref = RollingFile
-log4j2.rootLogger.appenderRef.AuditFile.ref = AuditFile
log4j2.rootLogger.appenderRef.PaxOsgi.ref = PaxOsgi
log4j2.rootLogger.appenderRef.Console.ref = Console
log4j2.rootLogger.appenderRef.Console.filter.regex.type = RegexFilter
log4j2.rootLogger.appenderRef.Console.filter.regex.regex = .*Audit.*
log4j2.rootLogger.appenderRef.Console.filter.regex.onMatch = DENY
-log4j2.rootLogger.appenderRef.Console.filter.regex.onMisMatch = ACCEPT
+log4j2.rootLogger.appenderRef.Console.filter.regex.onMismatch = ACCEPT
#log4j2.rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter
#log4j2.rootLogger.appenderRef.Console.filter.threshold.level = ${karaf.log.console:-OFF}
@@ -86,7 +85,7 @@
log4j2.appender.rolling.filter.regex.type = RegexFilter
log4j2.appender.rolling.filter.regex.regex = .*AuditLog.*
log4j2.appender.rolling.filter.regex.onMatch = DENY
-log4j2.appender.rolling.filter.regex.onMisMatch = ACCEPT
+log4j2.appender.rolling.filter.regex.onMismatch = ACCEPT
log4j2.appender.rolling.fileName = ${karaf.data}/log/karaf.log
log4j2.appender.rolling.filePattern = ${karaf.data}/log/karaf.log.%i
# uncomment to not force a disk flush
@@ -144,3 +143,22 @@
#log4j2.logger.http-headers.level = DEBUG
#log4j2.logger.maven.name = org.ops4j.pax.url.mvn
#log4j2.logger.maven.level = TRACE
+
+# --- Example for a Kafka appender ---
+# Avoid recursive logging for Kafka
+# log4j2.logger.apacheKafka.name = org.apache.kafka
+# log4j2.logger.apacheKafka.level = INFO
+
+# Kafka appender definition
+# log4j2.appender.kafka.type = Kafka
+# log4j2.appender.kafka.name = Kafka
+# log4j2.appender.kafka.property.type = Property
+# log4j2.appender.kafka.property.name = bootstrap.servers
+# log4j2.appender.kafka.property.value = localhost:9092
+# log4j2.appender.kafka.topic = onos.log
+# Async send, no need to wait for Kafka ack for each record
+# log4j2.appender.kafka.syncSend = false
+# log4j2.kafka.pattern = {"@timestamp":"%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}","levelname":"%p","threadName":"%t","category":"%c{1}","bundle.id":"%X{bundle.id}","bundle.name":"%X{bundle.name}","bundle.version":"%X{bundle.version}","message":"%m"}%n
+# log4j2.appender.kafka.layout.type = PatternLayout
+# log4j2.appender.kafka.layout.pattern = ${log4j2.kafka.pattern}
+# log4j2.rootLogger.appenderRef.Kafka.ref = Kafka
\ No newline at end of file