logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1487518 - in /logging/log4j/log4j2/trunk: flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEvent.java flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumePersistentAppenderTest.java src/changes/changes.xml
Date Wed, 29 May 2013 15:41:12 GMT
Author: rgoers
Date: Wed May 29 15:41:11 2013
New Revision: 1487518

URL: http://svn.apache.org/r1487518
Log:
LOG4J2-268 - Add guid to FlumeEvent headers for non-Map Messages

Modified:
    logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEvent.java
    logging/log4j/log4j2/trunk/flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumePersistentAppenderTest.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEvent.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEvent.java?rev=1487518&r1=1487517&r2=1487518&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEvent.java
(original)
+++ logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEvent.java
Wed May 29 15:41:11 2013
@@ -128,11 +128,14 @@ public class FlumeEvent extends SimpleEv
         final String guid =  UUIDUtil.getTimeBasedUUID().toString();
         final Message message = event.getMessage();
         if (message instanceof MapMessage) {
+            // Add the guid to the Map so that it can be included in the Layout.
             ((MapMessage) message).put(GUID, guid);
             if (message instanceof StructuredDataMessage) {
                 addStructuredData(eventPrefix, headers, (StructuredDataMessage) message);
             }
             addMapData(eventPrefix, headers, (MapMessage) message);
+        } else {
+            headers.put(GUID, guid);
         }
 
         addContextData(mdcPrefix, headers, ctx);

Modified: logging/log4j/log4j2/trunk/flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumePersistentAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumePersistentAppenderTest.java?rev=1487518&r1=1487517&r2=1487518&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumePersistentAppenderTest.java
(original)
+++ logging/log4j/log4j2/trunk/flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumePersistentAppenderTest.java
Wed May 29 15:41:11 2013
@@ -29,6 +29,8 @@ import org.apache.flume.source.avro.Stat
 import org.apache.logging.log4j.EventLogger;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.MarkerManager;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
 import org.apache.logging.log4j.message.StructuredDataMessage;
@@ -215,6 +217,20 @@ public class FlumePersistentAppenderTest
             Assert.assertTrue("Channel contained event, but not expected message " + i, fields[i]);
         }
     }
+
+    @Test
+    public void testSingle() throws InterruptedException, IOException {
+
+        Logger logger = LogManager.getLogger("EventLogger");
+        Marker marker = MarkerManager.getMarker("EVENT");
+        logger.info(marker, "This is a test message");
+
+        final Event event = primary.poll();
+        Assert.assertNotNull(event);
+        final String body = getBody(event);
+        Assert.assertTrue("Channel contained event, but not expected message. Received: "
+ body,
+            body.endsWith("This is a test message"));
+    }
     /*
     @Test
     public void testPerformance() throws Exception {

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1487518&r1=1487517&r2=1487518&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Wed May 29 15:41:11 2013
@@ -22,6 +22,9 @@
   </properties>
   <body>
     <release version="2.0-beta7" date="2013-??-??" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-268" dev="rgoers" type="fix">
+        Add guid to FlumeEvent headers for non-Map Messages.
+      </action>
       <action issue="LOG4J2-246" dev="rgoers" type="fix">
         Data buffer is reset in finally clause.
       </action>



Mime
View raw message