logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1487687 - in /logging/log4j/log4j2/trunk: flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/ flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/ flume-ng/src/test/resources/ src/changes/ src/site/xdoc/manual/
Date Thu, 30 May 2013 00:11:30 GMT
Author: rgoers
Date: Thu May 30 00:11:29 2013
New Revision: 1487687

URL: http://svn.apache.org/r1487687
Log:
LOG4J2-262 - Add support for interceptors to Flume Embedded Appender

Modified:
    logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEmbeddedManager.java
    logging/log4j/log4j2/trunk/flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeEmbeddedAppenderTest.java
    logging/log4j/log4j2/trunk/flume-ng/src/test/resources/embedded.xml
    logging/log4j/log4j2/trunk/src/changes/changes.xml
    logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml

Modified: logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEmbeddedManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEmbeddedManager.java?rev=1487687&r1=1487686&r2=1487687&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEmbeddedManager.java
(original)
+++ logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEmbeddedManager.java
Thu May 30 00:11:29 2013
@@ -274,7 +274,8 @@ public class FlumeEmbeddedManager extend
                         throw new ConfigurationException(msg);
                     }
 
-                    if (upperKey.startsWith("SOURCES.")) {
+                    // Prohibit setting the sources as they are set above but allow interceptors
to be set
+                    if (upperKey.startsWith("SOURCES.") && !upperKey.startsWith("SOURCES.LOG4J-SOURCE.INTERCEPTORS"))
{
                         final String msg = "Specification of Sources is not allowed in Flume
Appender: " + key;
                         LOGGER.error(msg);
                         throw new ConfigurationException(msg);

Modified: logging/log4j/log4j2/trunk/flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeEmbeddedAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeEmbeddedAppenderTest.java?rev=1487687&r1=1487686&r2=1487687&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeEmbeddedAppenderTest.java
(original)
+++ logging/log4j/log4j2/trunk/flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumeEmbeddedAppenderTest.java
Thu May 30 00:11:29 2013
@@ -193,6 +193,18 @@ public class FlumeEmbeddedAppenderTest {
     }
 
     @Test
+    public void testHeaderAddedByInterceptor() throws InterruptedException, IOException {
+
+        final StructuredDataMessage msg = new StructuredDataMessage("Test", "Test Log4j",
"Test");
+        EventLogger.logEvent(msg);
+
+        final Event event = primary.poll();
+        Assert.assertNotNull(event);
+        String environmentHeader = event.getHeaders().get("environment");
+        Assert.assertEquals("local", environmentHeader);
+    }
+
+    @Test
     public void testPerformance() throws Exception {
         long start = System.currentTimeMillis();
         int count = 10000;

Modified: logging/log4j/log4j2/trunk/flume-ng/src/test/resources/embedded.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/flume-ng/src/test/resources/embedded.xml?rev=1487687&r1=1487686&r2=1487687&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/flume-ng/src/test/resources/embedded.xml (original)
+++ logging/log4j/log4j2/trunk/flume-ng/src/test/resources/embedded.xml Thu May 30 00:11:29
2013
@@ -4,6 +4,10 @@
     <Flume name="eventLogger" suppressExceptions="false" compress="true" type="embedded">
       <Property name="channels">primary</Property>
       <Property name="channels.primary.type">memory</Property>
+      <Property name="sources.log4j-source.interceptors">environment_interceptor</Property>
+      <Property name="sources.log4j-source.interceptors.environment_interceptor.type">static</Property>
+      <Property name="sources.log4j-source.interceptors.environment_interceptor.key">environment</Property>
+      <Property name="sources.log4j-source.interceptors.environment_interceptor.value">local</Property>
       <Property name="sinks">agent1 agent2</Property>
       <Property name="sinks.agent1.channel">primary</Property>
       <Property name="sinks.agent1.type">avro</Property>

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1487687&r1=1487686&r2=1487687&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Thu May 30 00:11:29 2013
@@ -22,6 +22,9 @@
   </properties>
   <body>
     <release version="2.0-beta7" date="2013-??-??" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-262" dev="rgoers" type="update" due-to="Edward Sargisson">
+        Add support for interceptors in the embedded Flume Appender.
+      </action>
       <action issue="LOG4J2-269" dev="rgoers" type="fix">
         Use transaction when batch size is 1.
       </action>

Modified: logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml?rev=1487687&r1=1487686&r2=1487687&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml (original)
+++ logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml Thu May 30 00:11:29 2013
@@ -878,7 +878,8 @@
               <td>Property[]</td>
               <td><p>One or more Property elements that are used to configure
the Flume Agent. The properties must be
                 configured without the agent name (the appender name is used for this) and
no sources can be
-                configured. All other Flume configuration properties are allowed. Specifying
both Agent and Property
+                configured. Interceptors can be specified for the source using "sources.log4j-source.interceptors".

+                All other Flume configuration properties are allowed. Specifying both Agent
and Property
                 elements will result in an error.</p>
                 <p>When used to configure in Persistent mode the valid properties are:
                   <ol>



Mime
View raw message