[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-42-g4fadcb4
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Tue Oct 25 16:08:02 CEST 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via 4fadcb4ae7e8bac392524a37e9ab1a3a8159b6fe (commit)
from 1e59f24cc91a372e4ab8d13eab3a20b20b079a23 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=4fadcb4ae7e8bac392524a37e9ab1a3a8159b6fe
http://github.com/ceki/logback/commit/4fadcb4ae7e8bac392524a37e9ab1a3a8159b6fe
commit 4fadcb4ae7e8bac392524a37e9ab1a3a8159b6fe
Author: Ceki Gulcu <ceki at qos.ch>
Date: Tue Oct 25 16:07:45 2011 +0200
fix LBACCESS-27
diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java b/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java
index d688418..2d06115 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java
@@ -25,7 +25,11 @@ import ch.qos.logback.core.UnsynchronizedAppenderBase;
import ch.qos.logback.core.filter.EvaluatorFilter;
import ch.qos.logback.core.joran.JoranConfiguratorBase;
import ch.qos.logback.core.joran.action.AppenderRefAction;
+import ch.qos.logback.core.joran.action.IncludeAction;
import ch.qos.logback.core.joran.action.NOPAction;
+import ch.qos.logback.core.joran.conditional.ElseAction;
+import ch.qos.logback.core.joran.conditional.IfAction;
+import ch.qos.logback.core.joran.conditional.ThenAction;
import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.joran.spi.RuleStore;
@@ -33,6 +37,7 @@ import ch.qos.logback.core.joran.spi.RuleStore;
/**
+ * This JoranConfiguratorclass adds rules specific to logback-access.
*
* @author Ceki Gülcü
*/
@@ -49,6 +54,15 @@ public class JoranConfigurator extends JoranConfiguratorBase {
rs.addRule(new Pattern("configuration/appender/sift/*"), new NOPAction());
rs.addRule(new Pattern("configuration/evaluator"), new EvaluatorAction());
+
+ // add if-then-else support
+ rs.addRule(new Pattern("*/if"), new IfAction());
+ rs.addRule(new Pattern("*/if/then"), new ThenAction());
+ rs.addRule(new Pattern("*/if/then/*"), new NOPAction());
+ rs.addRule(new Pattern("*/if/else"), new ElseAction());
+ rs.addRule(new Pattern("*/if/else/*"), new NOPAction());
+
+ rs.addRule(new Pattern("configuration/include"), new IncludeAction());
}
@Override
diff --git a/logback-access/src/test/input/joran/conditional/conditionalConsole.xml b/logback-access/src/test/input/joran/conditional/conditionalConsole.xml
new file mode 100644
index 0000000..1ce7b68
--- /dev/null
+++ b/logback-access/src/test/input/joran/conditional/conditionalConsole.xml
@@ -0,0 +1,17 @@
+
+<configuration>
+
+ <if condition='property("HOSTNAME").contains("${aHost}")'>
+ <then>
+ <appender name="CON" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%h %l %u %user %date "%r" %s %b</pattern>
+ </encoder>
+ </appender>
+
+ <appender-ref ref="CON" />
+
+ </then>
+ </if>
+
+</configuration>
\ No newline at end of file
diff --git a/logback-access/src/test/input/joran/conditional/conditionalConsole_ELSE.xml b/logback-access/src/test/input/joran/conditional/conditionalConsole_ELSE.xml
new file mode 100644
index 0000000..4d3bd85
--- /dev/null
+++ b/logback-access/src/test/input/joran/conditional/conditionalConsole_ELSE.xml
@@ -0,0 +1,20 @@
+
+<configuration>
+
+ <if condition='property("HOSTNAME").contains("XYZ88")'>
+ <then>
+ <appender name="CON" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%h %l %u %user %date "%r" %s %b</pattern>
+ </encoder>
+ </appender>
+
+ <appender-ref ref="CON" />
+ </then>
+ <else>
+ <appender name="LIST" class="ch.qos.logback.core.read.ListAppender"/>
+ <appender-ref ref="LIST" />
+ </else>
+ </if>
+
+</configuration>
\ No newline at end of file
diff --git a/logback-access/src/test/java/ch/qos/logback/access/AllAccessTest.java b/logback-access/src/test/java/ch/qos/logback/access/AllAccessTest.java
index de85c65..2971d7d 100644
--- a/logback-access/src/test/java/ch/qos/logback/access/AllAccessTest.java
+++ b/logback-access/src/test/java/ch/qos/logback/access/AllAccessTest.java
@@ -22,6 +22,7 @@ import org.junit.runners.Suite.SuiteClasses;
ch.qos.logback.access.boolex.PackageTest.class,
ch.qos.logback.access.net.PackageTest.class,
ch.qos.logback.access.pattern.PackageTest.class,
+ ch.qos.logback.access.joran.PackageTest.class,
ch.qos.logback.access.jetty.PackageTest.class,
ch.qos.logback.access.filter.PackageTest.class,
ch.qos.logback.access.servlet.PackageTest.class,
diff --git a/logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java b/logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java
new file mode 100644
index 0000000..16a2bea
--- /dev/null
+++ b/logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java
@@ -0,0 +1,84 @@
+package ch.qos.logback.access.joran;
+
+import ch.qos.logback.access.TeztConstants;
+import ch.qos.logback.access.spi.AccessContext;
+import ch.qos.logback.core.ConsoleAppender;
+import ch.qos.logback.core.FileAppender;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.read.ListAppender;
+import ch.qos.logback.core.status.StatusChecker;
+import ch.qos.logback.core.testUtil.RandomUtil;
+import ch.qos.logback.core.util.CoreTestConstants;
+import ch.qos.logback.core.util.StatusPrinter;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Ceki Gücü
+ */
+public class ConditionalTest {
+
+ AccessContext context = new AccessContext();
+ StatusChecker checker = new StatusChecker(context);
+
+ int diff = RandomUtil.getPositiveInt();
+ String randomOutputDir = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "/";
+
+ @Before
+ public void setUp() {
+ InetAddress localhost = null;
+ try {
+ localhost = InetAddress.getLocalHost();
+ context.putProperty("aHost", localhost.getHostName());
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+ }
+
+ void configure(String file) throws JoranException {
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(context);
+ jc.doConfigure(file);
+ }
+
+ @Test
+ public void conditionalConsoleApp_IF_THEN_True() throws JoranException, UnknownHostException {
+ configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/conditional/conditionalConsole.xml");
+ ConsoleAppender consoleAppender = (ConsoleAppender) context.getAppender("CON");
+ assertNotNull(consoleAppender);
+ assertTrue(checker.isErrorFree(0));
+ }
+
+ @Test
+ public void conditionalConsoleApp_IF_THEN_False() throws JoranException,
+ IOException, InterruptedException {
+ context.putProperty("aHost", null);
+ configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/conditional/conditionalConsole.xml");
+
+ ConsoleAppender consoleAppender = (ConsoleAppender) context.getAppender("CON");
+ assertNull(consoleAppender);
+
+ StatusChecker checker = new StatusChecker(context);
+ assertTrue(checker.isErrorFree(0));
+ }
+
+ @Test
+ public void conditionalConsoleApp_ELSE() throws JoranException,
+ IOException, InterruptedException {
+ configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/conditional/conditionalConsole_ELSE.xml");
+ ConsoleAppender consoleAppender = (ConsoleAppender) context.getAppender("CON");
+ assertNull(consoleAppender);
+
+ ListAppender listAppender = (ListAppender) context.getAppender("LIST");
+ assertNotNull(listAppender);
+ assertTrue(checker.isErrorFree(0));
+ }
+}
diff --git a/logback-access/src/test/java/ch/qos/logback/access/joran/PackageTest.java b/logback-access/src/test/java/ch/qos/logback/access/joran/PackageTest.java
new file mode 100644
index 0000000..b79b7ca
--- /dev/null
+++ b/logback-access/src/test/java/ch/qos/logback/access/joran/PackageTest.java
@@ -0,0 +1,12 @@
+package ch.qos.logback.access.joran;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Ceki Gücü
+ */
+ at RunWith(Suite.class)
+ at Suite.SuiteClasses({JoranConfiguratorTest.class, ConditionalTest.class})
+public class PackageTest {
+}
diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml
index da0175a..5dc62fb 100644
--- a/logback-classic/pom.xml
+++ b/logback-classic/pom.xml
@@ -339,7 +339,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <!-- once, never, -->
+ <!-- once, never, pertest, always -->
<forkMode>once</forkMode>
<reportFormat>plain</reportFormat>
<trimStackTrace>false</trimStackTrace>
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
index 4334d32..46c8f73 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
@@ -30,7 +30,7 @@ import ch.qos.logback.core.joran.spi.RuleStore;
/**
* This JoranConfiguratorclass adds rules specific to logback-classic.
- *
+ *
* @author Ceki Gülcü
*/
public class JoranConfigurator extends JoranConfiguratorBase {
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
index 4884ea6..1e345a2 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
@@ -373,9 +373,11 @@ public class JoranConfiguratorTest {
public void levelChangePropagator1() throws JoranException, IOException,
InterruptedException {
java.util.logging.Logger.getLogger("xx").setLevel(java.util.logging.Level.INFO);
+ verifyJULLevel("xx", Level.INFO);
String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
+ "/jul/levelChangePropagator1.xml";
configure(configFileAsStr);
+ StatusPrinter.print(loggerContext);
StatusChecker checker = new StatusChecker(loggerContext);
assertTrue(checker.isErrorFree(0));
verifyJULLevel("xx", Level.INFO);
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 4561ba9..fa96c57 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -66,6 +66,17 @@
href="http://jira.qos.ch/browse/LBCORE-225">LBCORE-225</a>
reported by Mark Woon.</p>
+ <p>Logback-access now supports conditional configuration. This
+ fixes <a
+ href="http://jira.qos.ch/browse/LBACCESS-27">LBACCESS-27</a>
+ reported by Marshall Pierce.</p>
+
+ <p>Logback-access now supports inclusion of configuration
+ files. See the <a
+ href="manual/configuration.html#fileInclusion">chapter about
+ configuration</a> in the logback's online manual for more
+ information. </p>
+
<p>Added <code>ch.qos.logback.core.read</code> to "Import-Package"
declaration in logback-classic's manifest file. This fixes <a
href="http://jira.qos.ch/browse/LBCLASSIC-131">LBCLASSIC-131</a>
@@ -1500,7 +1511,7 @@ ALTER TABLE logging_event ADD arg3 VARCHAR(254);</pre>
logback's configuration framework. A file can contain an
<em>include</em> element that has a <em>file</em> or <em>url</em>
attribute pointing to a configuration file. See the <a
- href="manual/configuration.html#Include">chapter about
+ href="manual/configuration.html#fileInclusion">chapter about
configuration</a> in the logback's online manual for more
information.
</p>
-----------------------------------------------------------------------
Summary of changes:
.../logback/access/joran/JoranConfigurator.java | 14 +++
.../input/joran/conditional/conditionalConsole.xml | 17 ++++
.../joran/conditional/conditionalConsole_ELSE.xml | 20 +++++
.../java/ch/qos/logback/access/AllAccessTest.java | 1 +
.../qos/logback/access/joran/ConditionalTest.java | 84 ++++++++++++++++++++
.../ch/qos/logback/access/joran/PackageTest.java | 12 +++
logback-classic/pom.xml | 2 +-
.../logback/classic/joran/JoranConfigurator.java | 2 +-
.../classic/joran/JoranConfiguratorTest.java | 2 +
logback-site/src/site/pages/news.html | 13 +++-
10 files changed, 164 insertions(+), 3 deletions(-)
create mode 100644 logback-access/src/test/input/joran/conditional/conditionalConsole.xml
create mode 100644 logback-access/src/test/input/joran/conditional/conditionalConsole_ELSE.xml
create mode 100644 logback-access/src/test/java/ch/qos/logback/access/joran/ConditionalTest.java
create mode 100644 logback-access/src/test/java/ch/qos/logback/access/joran/PackageTest.java
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list