logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1185679 - in /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src: main/java/org/apache/logging/log4j/core/appender/ main/java/org/apache/logging/log4j/core/config/ main/java/org/apache/logging/log4j/core/config/plugins/ ...
Date Tue, 18 Oct 2011 14:20:34 GMT
Author: rgoers
Date: Tue Oct 18 14:20:33 2011
New Revision: 1185679

URL: http://svn.apache.org/viewvc?rev=1185679&view=rev
Log:
Add FailoverAppender. Ignore case in element names

Added:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java
      - copied, changed from r1178316, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoversPlugin.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/AlwaysFailAppender.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-failover.xml
      - copied, changed from r1147720, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test1.xml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j12-perf2.xml
      - copied unchanged from r1157554, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j12-perf2xml
Removed:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j12-perf2xml
Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java

Copied: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java
(from r1178316, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java?p2=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java&p1=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java&r1=1178316&r2=1185679&rev=1185679&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/JMSQueueAppender.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java
Tue Oct 18 14:20:33 2011
@@ -16,67 +16,145 @@
  */
 package org.apache.logging.log4j.core.appender;
 
-import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.LoggingException;
+import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.config.AppenderControl;
+import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
 import org.apache.logging.log4j.core.config.plugins.PluginAttr;
+import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
 import org.apache.logging.log4j.core.config.plugins.PluginElement;
 import org.apache.logging.log4j.core.config.plugins.PluginFactory;
 import org.apache.logging.log4j.core.filter.Filters;
-import org.apache.logging.log4j.core.layout.SerializedLayout;
-import org.apache.logging.log4j.core.net.JMSQueueManager;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 /**
- *
+ * The FailoverAppender will capture exceptions in an Appender and then route the event
+ * to a different appender. Hopefully it is obvious that the Appenders must be configured
+ * to not suppress exceptions for the FailoverAppender to work.
  */
-@Plugin(name="JMSQueue",type="Core",elementType="appender",printObject=true)
-public class JMSQueueAppender extends AppenderBase {
+@Plugin(name="Failover",type="Core",elementType="appender",printObject=true)
+public class FailoverAppender extends AppenderBase {
+
+    private final String primaryRef;
+
+    private final String[] failovers;
+
+    private final Configuration config;
 
-    private final JMSQueueManager manager;
+    private AppenderControl primary;
+
+    private List<AppenderControl> failoverAppenders = new ArrayList<AppenderControl>();
+
+
+    public FailoverAppender(String name, Filters filters, String primary, String[] failovers,
+                            Configuration config, boolean handleExceptions) {
+        super(name, filters, null, handleExceptions);
+        this.primaryRef = primary;
+        this.failovers = failovers;
+        this.config = config;
+    }
+
+
+    @Override
+    public void start() {
+        Map<String, Appender> map = config.getAppenders();
+        int errors = 0;
+        if (map.containsKey(primaryRef)) {
+            primary = new AppenderControl(map.get(primaryRef));
+        } else {
+            logger.error("Unable to locate primary Appender " + primaryRef);
+            ++errors;
+        }
+        for (String name : failovers) {
+            if (map.containsKey(name)) {
+                failoverAppenders.add(new AppenderControl(map.get(name)));
+            } else {
+                logger.error("Failover appender " + name + " is not configured");
+            }
+        }
+        if (failoverAppenders.size() == 0) {
+            logger.error("No failover appenders are available");
+            ++errors;
+        }
+        if (errors == 0) {
+            super.start();
+        }
+    }
+
+    @Override
+    public void stop() {
+        super.stop();
+    }
 
-    public JMSQueueAppender(String name, Filters filters, Layout layout, JMSQueueManager
manager,
-                            boolean handleExceptions) {
-        super(name, filters, layout, handleExceptions);
-        this.manager = manager;
-    }
-
-    /**
-     * Actual writing occurs here.
-     * <p/>
-     * @param event The LogEvent.
-     */
     public void append(LogEvent event) {
+        RuntimeException re = null;
+        if (!isStarted()) {
+            error("FailoverAppender " + getName() + " did not start successfully");
+            return;
+        }
         try {
-            manager.send(getLayout().formatAs(event));
+            primary.callAppender(event);
         } catch (Exception ex) {
-            throw new AppenderRuntimeException(ex);
+            re = new LoggingException(ex);
+            boolean written = false;
+            for (AppenderControl control : failoverAppenders) {
+                try {
+                    control.callAppender(event);
+                    written = true;
+                    break;
+                } catch (Exception fex) {
+                    // Try the next failover.
+                }
+            }
+            if (!written && !isExceptionSuppressed()) {
+                throw re;
+            }
         }
     }
 
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder(getName());
+        sb.append(" primary=").append(primary).append(", failover={");
+        boolean first = true;
+        for (String str : failovers) {
+            if (!first) {
+                sb.append(", ");
+            }
+            sb.append(str);
+            first = false;
+        }
+        sb.append("}");
+        return sb.toString();
+    }
+
     @PluginFactory
-    public static JMSQueueAppender createAppender(@PluginAttr("factoryName") String factoryName,
-                                                  @PluginAttr("providerURL") String providerURL,
-                                                  @PluginAttr("urlPkgPrefixes") String urlPkgPrefixes,
-                                                  @PluginAttr("securityPrincipalName") String
securityPrincipalName,
-                                                  @PluginAttr("securityCredentials") String
securityCredentials,
-                                                  @PluginAttr("factoryBindingName") String
factoryBindingName,
-                                                  @PluginAttr("queueBindingName") String
queueBindingName,
-                                                  @PluginAttr("userName") String userName,
-                                                  @PluginAttr("password") String password,
-                                                  @PluginElement("layout") Layout layout,
+    public static FailoverAppender createAppender(@PluginAttr("name") String name,
+                                                  @PluginAttr("primary") String primary,
+                                                  @PluginElement("failovers") String[] failovers,
+                                                  @PluginConfiguration Configuration config,
                                                   @PluginElement("filters") Filters filters,
                                                   @PluginAttr("suppressExceptions") String
suppress) {
-
-        String name = "JMSQueue" + factoryBindingName + "." + queueBindingName;
-        boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
-        JMSQueueManager manager = JMSQueueManager.getJMSQueueManager(factoryName, providerURL,
urlPkgPrefixes,
-            securityPrincipalName, securityCredentials, factoryBindingName, queueBindingName,
userName, password);
-        if (manager == null) {
+        if (name == null) {
+            logger.error("A name for the Appender must be specified");
+            return null;
+        }
+        if (primary == null) {
+            logger.error("A primary Appender must be specified");
             return null;
         }
-        if (layout == null) {
-            layout = SerializedLayout.createLayout();
+        if (failovers == null || failovers.length == 0) {
+            logger.error("At least one failover Appender must be specified");
+            return null;
         }
-        return new JMSQueueAppender(name, filters, layout, manager, handleExceptions);
+
+        boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
+
+        return new FailoverAppender(name, filters, primary, failovers, config, handleExceptions);
     }
 }

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoversPlugin.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoversPlugin.java?rev=1185679&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoversPlugin.java
(added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/FailoversPlugin.java
Tue Oct 18 14:20:33 2011
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginElement;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.status.StatusLogger;
+
+/**
+ *
+ */
+@Plugin(name="failovers",type="Core")
+public class FailoversPlugin {
+
+    private static Logger logger = StatusLogger.getLogger();
+
+    @PluginFactory
+    public static String[] createFailovers(@PluginElement("appender-ref") String[] refs)
{
+
+        if (refs == null) {
+            logger.error("failovers must contain an appender-refernce");
+        }
+        return refs;
+    }
+}

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java?rev=1185679&r1=1185678&r2=1185679&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
Tue Oct 18 14:20:33 2011
@@ -122,11 +122,11 @@ public class BaseConfiguration extends F
             }
             if (child.getName().equalsIgnoreCase("properties")) {
                 subst = (StrSubstitutor) child.getObject();
-            } else if (child.getName().equals("appenders")) {
+            } else if (child.getName().equalsIgnoreCase("appenders")) {
                 appenders = (ConcurrentMap<String, Appender>) child.getObject();
-            } else if (child.getName().equals("filters")) {
+            } else if (child.getName().equalsIgnoreCase("filters")) {
                 setFilters((Filters) child.getObject());
-            } else if (child.getName().equals("loggers")) {
+            } else if (child.getName().equalsIgnoreCase("loggers")) {
                 Loggers l = (Loggers) child.getObject();
                 loggers = l.getMap();
                 setLoggers = true;
@@ -578,7 +578,7 @@ public class BaseConfiguration extends F
                         boolean first = true;
                         for (Node child : children) {
                             PluginType childType = child.getType();
-                            if (elem.value().equals(childType.getElementName()) ||
+                            if (elem.value().equalsIgnoreCase(childType.getElementName())
||
                                 parmClass.isAssignableFrom(childType.getPluginClass())) {
                                 used.add(child);
                                 if (!first) {

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java?rev=1185679&r1=1185678&r2=1185679&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
Tue Oct 18 14:20:33 2011
@@ -57,7 +57,7 @@ public class PluginManager {
     }
 
     public PluginType getPluginType(String name) {
-        return plugins.get(name);
+        return plugins.get(name.toLowerCase());
     }
 
     public Map<String, PluginType> getPlugins() {
@@ -79,7 +79,7 @@ public class PluginManager {
         {
             Plugin p = item.getAnnotation(Plugin.class);
             String type = p.elementType().equals(Plugin.NULL) ? p.name() : p.elementType();
-            plugins.put(p.name(), new PluginType(item, type, p.printObject(), p.deferChildren()));
+            plugins.put(p.name().toLowerCase(), new PluginType(item, type, p.printObject(),
p.deferChildren()));
         }
     }
 

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/AlwaysFailAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/AlwaysFailAppender.java?rev=1185679&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/AlwaysFailAppender.java
(added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/AlwaysFailAppender.java
Tue Oct 18 14:20:33 2011
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender;
+
+import org.apache.logging.log4j.LoggingException;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttr;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+
+/**
+ *
+ */
+@Plugin(name="AlwaysFail",type="Core",elementType="appender",printObject=true)
+public class AlwaysFailAppender extends AppenderBase {
+
+    private AlwaysFailAppender(String name) {
+        super(name, null, null, false);
+    }
+
+    public void append(LogEvent event) {
+        throw new LoggingException("Always fail");
+    }
+
+    @PluginFactory
+    public static AlwaysFailAppender createAppender(@PluginAttr("name") String name) {
+        if (name == null) {
+            logger.error("A name for the Appender must be specified");
+            return null;
+        }
+
+        return new AlwaysFailAppender(name);
+    }
+
+}

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java?rev=1185679&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
(added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FailoverAppenderTest.java
Tue Oct 18 14:20:33 2011
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ *
+ */
+public class FailoverAppenderTest {
+    private static final String CONFIG = "log4j-failover.xml";
+    private static Configuration config;
+    private static ListAppender app;
+    private static LoggerContext ctx;
+
+    @BeforeClass
+    public static void setupClass() {
+        System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
+        ctx = (LoggerContext) LogManager.getContext(false);
+        config = ctx.getConfiguration();
+        for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet())
{
+            if (entry.getKey().equals("List")) {
+                app = (ListAppender) entry.getValue();
+                break;
+            }
+        }
+    }
+
+    @AfterClass
+    public static void cleanupClass() {
+        System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+        ctx.reconfigure();
+        StatusLogger.getLogger().reset();
+    }
+
+    org.apache.logging.log4j.Logger logger = LogManager.getLogger("LoggerTest");
+
+    @Test
+    public void testFailover() {
+        logger.error("This is a test");
+        List<LogEvent> events = app.getEvents();
+        assertNotNull(events);
+        assertTrue("Incorrect number of events. Should be 1 is " + events.size(), events.size()
== 1);
+        app.clear();
+        logger.error("This is a test");
+        events = app.getEvents();
+        assertNotNull(events);
+        assertTrue("Incorrect number of events. Should be 1 is " + events.size(), events.size()
== 1);
+    }
+}

Copied: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-failover.xml
(from r1147720, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test1.xml)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-failover.xml?p2=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-failover.xml&p1=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test1.xml&r1=1147720&r2=1185679&rev=1185679&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test1.xml
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-failover.xml
Tue Oct 18 14:20:33 2011
@@ -1,44 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<configuration packages="" status="warn" name="XMLConfigTest">
-  <properties>
-    <property name="filename">target/test.log</property>
-  </properties>
-  <filters>
-    <Threshold level="debug"/>
-  </filters>
-
-  <appenders>
-    <Console name="STDOUT">
-      <PatternLayout pattern="%m%n"/>
-    </Console>
-    <File name="File" fileName="${filename}" bufferedIO="false">
-      <PatternLayout>
-        <pattern>%d %p %C{1.} [%t] %m%n</pattern>
-      </PatternLayout>
-    </File>
-    <List name="List">
-      <filters>
-        <Threshold level="error"/>
-      </filters>
-    </List>
-  </appenders>
+<configuration packages="" status="error" name="FailoverTest">
+  <Appenders>
+    <AlwaysFail name="Fail" />
+    <List name="List" />
+    <Failover name="Failover" primary="Fail" suppressExceptions="false">
+      <Failovers>
+        <appender-ref ref="List"/>
+      </Failovers>
+    </Failover>
+  </Appenders>
 
   <loggers>
-    <logger name="org.apache.logging.log4j.test1" level="debug" additivity="false">
-      <filters>
-        <ThreadContextMap>
-          <KeyValuePair key="test" value="123"/>
-        </ThreadContextMap>
-      </filters>
-      <appender-ref ref="STDOUT"/>
-    </logger>>
-
-    <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
-      <appender-ref ref="File"/>
-    </logger>>
-
     <root level="error">
-      <appender-ref ref="STDOUT"/>
+      <appender-ref ref="Failover"/>
     </root>
   </loggers>
 



Mime
View raw message