logback-dev
Threads by month
- ----- 2025 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
October 2011
- 9 participants
- 130 discussions

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-50-g8f6d534
by git-noreply@pixie.qos.ch 26 Oct '11
by git-noreply@pixie.qos.ch 26 Oct '11
26 Oct '11
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 8f6d5349ae6d3286726a74188512f249ea352866 (commit)
from 30bf0d638f0b95bac0ed0912f059d187c560b73d (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=8f6d5349ae6d3286726a7418…
http://github.com/ceki/logback/commit/8f6d5349ae6d3286726a74188512f249ea352…
commit 8f6d5349ae6d3286726a74188512f249ea352866
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Wed Oct 26 13:27:12 2011 +0200
ongoing work
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
index 1c2acb0..df3ecd6 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
@@ -13,9 +13,9 @@
*/
package ch.qos.logback.classic.turbo;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.*;
import java.net.MalformedURLException;
@@ -344,14 +344,10 @@ public class ReconfigureOnChangeTest {
enum UpdateType {TOUCH, MALFORMED, MALFORMED_INNER}
- void writeToFile(File file, String contents) {
- try {
- FileWriter fw = new FileWriter(file);
- fw.write(contents);
- fw.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ void writeToFile(File file, String contents) throws IOException {
+ FileWriter fw = new FileWriter(file);
+ fw.write(contents);
+ fw.close();
}
class Updater extends RunnableWithCounterAndDone {
@@ -383,21 +379,31 @@ public class ReconfigureOnChangeTest {
touchFile();
break;
case MALFORMED:
- malformedUpdate(counter);
+ try {
+ malformedUpdate(counter);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("malformedUpdate failed");
+ }
break;
case MALFORMED_INNER:
- malformedInnerUpdate(counter);
+ try {
+ malformedInnerUpdate(counter);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("malformedInnerUpdate failed");
+ }
}
}
}
- private void malformedUpdate(long counter) {
+ private void malformedUpdate(long counter) throws IOException {
writeToFile(configFile, "<configuration scan=\"true\" scanPeriod=\"50 millisecond\">\n" +
" <root level=\"ERROR\">\n" +
"</configuration>");
}
- private void malformedInnerUpdate(long counter) {
+ private void malformedInnerUpdate(long counter) throws IOException {
writeToFile(configFile, "<included>\n" +
" <root>\n" +
"</included>");
-----------------------------------------------------------------------
Summary of changes:
.../classic/turbo/ReconfigureOnChangeTest.java | 32 ++++++++++++--------
1 files changed, 19 insertions(+), 13 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-49-g30bf0d6
by git-noreply@pixie.qos.ch 26 Oct '11
by git-noreply@pixie.qos.ch 26 Oct '11
26 Oct '11
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 30bf0d638f0b95bac0ed0912f059d187c560b73d (commit)
from a11c40845b39152164339eba89579eab30c3d7e2 (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=30bf0d638f0b95bac0ed0912…
http://github.com/ceki/logback/commit/30bf0d638f0b95bac0ed0912f059d187c560b…
commit 30bf0d638f0b95bac0ed0912f059d187c560b73d
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Wed Oct 26 13:09:14 2011 +0200
upgrade to surefire 2.10, fix ContextDetachingSCLTest
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java b/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java
index f437dda..05ffa57 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java
@@ -70,7 +70,7 @@ public class LevelChangePropagator extends ContextAwareBase implements LoggerCon
String loggerName = (String) e.nextElement();
java.util.logging.Logger julLogger = lm.getLogger(loggerName);
if (JULHelper.isRegularNonRootLogger(julLogger) && julLogger.getLevel() != null) {
- addInfo("Setting **** level of jul logger [" + loggerName + "] to null");
+ addInfo("Setting level of jul logger [" + loggerName + "] to null");
julLogger.setLevel(null);
}
}
diff --git a/logback-classic/src/test/input/joran/jul/levelChangePropagator0.xml b/logback-classic/src/test/input/joran/jul/levelChangePropagator0.xml
index 026462f..6052995 100644
--- a/logback-classic/src/test/input/joran/jul/levelChangePropagator0.xml
+++ b/logback-classic/src/test/input/joran/jul/levelChangePropagator0.xml
@@ -1,6 +1,3 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE configuration>
-
<configuration debug="false">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
diff --git a/logback-classic/src/test/input/joran/jul/levelChangePropagator1.xml b/logback-classic/src/test/input/joran/jul/levelChangePropagator1.xml
index cb73f2f..a7f4d4e 100644
--- a/logback-classic/src/test/input/joran/jul/levelChangePropagator1.xml
+++ b/logback-classic/src/test/input/joran/jul/levelChangePropagator1.xml
@@ -1,6 +1,3 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE configuration>
-
<configuration debug="false">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
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 188b222..8f85033 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
@@ -24,6 +24,7 @@ import ch.qos.logback.classic.jul.JULHelper;
import ch.qos.logback.core.pattern.parser.Parser;
import ch.qos.logback.core.pattern.parser.ScanException;
import ch.qos.logback.core.status.Status;
+import ch.qos.logback.core.testUtil.RandomUtil;
import ch.qos.logback.core.util.CachingDateFormatter;
import ch.qos.logback.core.util.StatusPrinter;
import org.junit.Ignore;
@@ -55,6 +56,7 @@ public class JoranConfiguratorTest {
Logger logger = loggerContext.getLogger(this.getClass().getName());
Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
StatusChecker sc = new StatusChecker(loggerContext);
+ int diff = RandomUtil.getPositiveInt();
void configure(String file) throws JoranException {
JoranConfigurator jc = new JoranConfigurator();
@@ -363,13 +365,15 @@ public class JoranConfiguratorTest {
@Test
public void levelChangePropagator0() throws JoranException, IOException,
InterruptedException {
- java.util.logging.Logger.getLogger("xx").setLevel(java.util.logging.Level.INFO);
+ String loggerName = "changePropagator0"+diff;
+ java.util.logging.Logger.getLogger(loggerName).setLevel(java.util.logging.Level.INFO);
String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
+ "/jul/levelChangePropagator0.xml";
configure(configFileAsStr);
+ StatusPrinter.print(loggerContext);
StatusChecker checker = new StatusChecker(loggerContext);
assertTrue(checker.isErrorFree(0));
- verifyJULLevel("xx", null);
+ verifyJULLevel(loggerName, null);
verifyJULLevel("a.b.c", Level.WARN);
verifyJULLevel(Logger.ROOT_LOGGER_NAME, Level.TRACE);
}
@@ -377,15 +381,16 @@ public class JoranConfiguratorTest {
@Test
public void levelChangePropagator1() throws JoranException, IOException,
InterruptedException {
- java.util.logging.Logger.getLogger("xx").setLevel(java.util.logging.Level.INFO);
- verifyJULLevel("xx", Level.INFO);
+ String loggerName = "changePropagator1"+diff;
+ java.util.logging.Logger.getLogger(loggerName).setLevel(java.util.logging.Level.INFO);
+ verifyJULLevel(loggerName, 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);
+ verifyJULLevel(loggerName, Level.INFO);
verifyJULLevel("a.b.c", Level.WARN);
verifyJULLevel(Logger.ROOT_LOGGER_NAME, Level.TRACE);
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java
index 1497689..a96c209 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java
@@ -25,19 +25,21 @@ import ch.qos.logback.classic.selector.servlet.ContextDetachingSCL;
import ch.qos.logback.classic.util.ContextSelectorStaticBinder;
import ch.qos.logback.classic.util.MockInitialContext;
import ch.qos.logback.classic.util.MockInitialContextFactory;
+import org.slf4j.LoggerFactoryFriend;
+import org.slf4j.impl.StaticLoggerBinderFriend;
public class ContextDetachingSCLTest {
static String INITIAL_CONTEXT_KEY = "java.naming.factory.initial";
- ContextDetachingSCL cobtextDetachingSCL;
+ ContextDetachingSCL contextDetachingSCL;
@Before
public void setUp() throws Exception {
+
System.setProperty(ClassicConstants.LOGBACK_CONTEXT_SELECTOR, "JNDI");
- //LoggerFactory.setup();
-
- cobtextDetachingSCL = new ContextDetachingSCL();
+
+ contextDetachingSCL = new ContextDetachingSCL();
MockInitialContextFactory.initialize();
MockInitialContext mic = MockInitialContextFactory.getContext();
@@ -45,21 +47,27 @@ public class ContextDetachingSCLTest {
//The property must be set after we setup the Mock
System.setProperty(INITIAL_CONTEXT_KEY, MockInitialContextFactory.class.getName());
-
+
+ // reinitialize the LoggerFactory, These reset methods are reserved for internal use
+ StaticLoggerBinderFriend.reset();
+ LoggerFactoryFriend.reset();
+
//this call will create the context "toto"
LoggerFactory.getLogger(ContextDetachingSCLTest.class);
-
}
@After
public void tearDown() throws Exception {
System.clearProperty(INITIAL_CONTEXT_KEY);
+ // reinitialize the LoggerFactory, These resets method are reserved for internal use
+ StaticLoggerBinderFriend.reset();
+ LoggerFactoryFriend.reset();
}
@Test
public void testDetach() {
ContextJNDISelector selector = (ContextJNDISelector) ContextSelectorStaticBinder.getSingleton().getContextSelector();
- cobtextDetachingSCL.contextDestroyed(null);
+ contextDetachingSCL.contextDestroyed(null);
assertEquals(0, selector.getCount());
}
@@ -73,7 +81,7 @@ public class ContextDetachingSCLTest {
mic.map.put(ClassicConstants.JNDI_CONTEXT_NAME, "titi");
assertEquals("titi", selector.getLoggerContext().getName());
- cobtextDetachingSCL.contextDestroyed(null);
+ contextDetachingSCL.contextDestroyed(null);
assertEquals(2, selector.getCount());
}
diff --git a/logback-core/pom.xml b/logback-core/pom.xml
index 5e64c4d..9d4ba41 100644
--- a/logback-core/pom.xml
+++ b/logback-core/pom.xml
@@ -124,7 +124,6 @@
<forkMode>once</forkMode>
<reportFormat>plain</reportFormat>
<parallel>classes</parallel>
-
<trimStackTrace>false</trimStackTrace>
<excludes>
<exclude>**/All*Test.java</exclude>
diff --git a/logback-examples/src/main/java/chapters/architecture/SelectionRule.java b/logback-examples/src/main/java/chapters/architecture/SelectionRule.java
index 7dbcc52..ba74fd5 100644
--- a/logback-examples/src/main/java/chapters/architecture/SelectionRule.java
+++ b/logback-examples/src/main/java/chapters/architecture/SelectionRule.java
@@ -1,51 +1,51 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package chapters.architecture;
-
-import ch.qos.logback.classic.Level;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Ceki Gücü
- */
-public class SelectionRule {
-
- public static void main(String[] args) {
- // get a logger instance named "com.foo". Let us further assume that the
- // logger is of type ch.qos.logback.classic.Logger so that we can
- // set its level
- ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("com.foo");
- //set its Level to INFO. The setLevel() method requires a logback logger
- logger.setLevel(Level.INFO);
-
- Logger barlogger = LoggerFactory.getLogger("com.foo.Bar");
-
- // This request is enabled, because WARN >= INFO
- logger.warn("Low fuel level.");
-
- // This request is disabled, because DEBUG < INFO.
- logger.debug("Starting search for nearest gas station.");
-
- // The logger instance barlogger, named "com.foo.Bar",
- // will inherit its level from the logger named
- // "com.foo" Thus, the following request is enabled
- // because INFO >= INFO.
- barlogger.info("Located nearest gas station.");
-
- // This request is disabled, because DEBUG < INFO.
- barlogger.debug("Exiting gas station search");
-
- }
-}
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package chapters.architecture;
+
+import ch.qos.logback.classic.Level;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Ceki Gücü
+ */
+public class SelectionRule {
+
+ public static void main(String[] args) {
+ // get a logger instance named "com.foo". Let us further assume that the
+ // logger is of type ch.qos.logback.classic.Logger so that we can
+ // set its level
+ ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("com.foo");
+ //set its Level to INFO. The setLevel() method requires a logback logger
+ logger.setLevel(Level.INFO);
+
+ Logger barlogger = LoggerFactory.getLogger("com.foo.Bar");
+
+ // This request is enabled, because WARN >= INFO
+ logger.warn("Low fuel level.");
+
+ // This request is disabled, because DEBUG < INFO.
+ logger.debug("Starting search for nearest gas station.");
+
+ // The logger instance barlogger, named "com.foo.Bar",
+ // will inherit its level from the logger named
+ // "com.foo" Thus, the following request is enabled
+ // because INFO >= INFO.
+ barlogger.info("Located nearest gas station.");
+
+ // This request is disabled, because DEBUG < INFO.
+ barlogger.debug("Exiting gas station search");
+
+ }
+}
diff --git a/pom.xml b/pom.xml
index 95d9c69..5a0c1d0 100755
--- a/pom.xml
+++ b/pom.xml
@@ -210,10 +210,11 @@
<target>1.5</target>
</configuration>
</plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.6</version>
+ <version>2.10</version>
</plugin>
<plugin>
-----------------------------------------------------------------------
Summary of changes:
.../logback/classic/jul/LevelChangePropagator.java | 2 +-
.../input/joran/jul/levelChangePropagator0.xml | 3 -
.../input/joran/jul/levelChangePropagator1.xml | 3 -
.../classic/joran/JoranConfiguratorTest.java | 15 ++-
.../classic/selector/ContextDetachingSCLTest.java | 24 +++--
logback-core/pom.xml | 1 -
.../java/chapters/architecture/SelectionRule.java | 102 ++++++++++----------
pom.xml | 3 +-
8 files changed, 80 insertions(+), 73 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-48-ga11c408
by git-noreply@pixie.qos.ch 26 Oct '11
by git-noreply@pixie.qos.ch 26 Oct '11
26 Oct '11
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 a11c40845b39152164339eba89579eab30c3d7e2 (commit)
from 9df24380d7a814b6db372781c520a1a9bf29b15b (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=a11c40845b39152164339eba…
http://github.com/ceki/logback/commit/a11c40845b39152164339eba89579eab30c3d…
commit a11c40845b39152164339eba89579eab30c3d7e2
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Wed Oct 26 09:02:30 2011 +0200
taking into account that a reset can occur while the harness thread is sleeping
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
index b63a079..1c2acb0 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
@@ -261,7 +261,10 @@ public class ReconfigureOnChangeTest {
String failMsg = "effective=" + effectiveResets + ", expected="
+ expected;
- assertEquals(failMsg, expected, effectiveResets);
+
+ // there might be more effective resets than the expected amount
+ // since the harness may be sleeping while a reset occurs
+ assertTrue(failMsg, expected <= effectiveResets && (expected +2) >= effectiveResets);
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java b/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java
index 0854e7a..24a4a30 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java
@@ -13,8 +13,8 @@ public class WaitOnExecutionMultiThreadedHarness extends AbstractMultiThreadedHa
}
@Override
void waitUntilEndCondition() throws InterruptedException {
- while(threadPoolExecutor.getCompletedTaskCount() != count) {
- Thread.sleep(100);
+ while(threadPoolExecutor.getCompletedTaskCount() < count) {
+ Thread.sleep(20);
}
}
}
-----------------------------------------------------------------------
Summary of changes:
.../classic/turbo/ReconfigureOnChangeTest.java | 5 ++++-
.../WaitOnExecutionMultiThreadedHarness.java | 4 ++--
2 files changed, 6 insertions(+), 3 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-47-g9df2438
by git-noreply@pixie.qos.ch 26 Oct '11
by git-noreply@pixie.qos.ch 26 Oct '11
26 Oct '11
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 9df24380d7a814b6db372781c520a1a9bf29b15b (commit)
from dea82f92852be5f4c191ebb06ff5c8254485428b (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=9df24380d7a814b6db372781…
http://github.com/ceki/logback/commit/9df24380d7a814b6db372781c520a1a9bf29b…
commit 9df24380d7a814b6db372781c520a1a9bf29b15b
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Wed Oct 26 08:03:52 2011 +0200
indentation changes only
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/SimpleKeywordNode.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/SimpleKeywordNode.java
index 6c21cf0..0b70287 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/SimpleKeywordNode.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/parser/SimpleKeywordNode.java
@@ -1,64 +1,64 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.core.pattern.parser;
-
-import java.util.List;
-
-public class SimpleKeywordNode extends FormattingNode {
-
- List<String> optionList;
-
- SimpleKeywordNode(Object value) {
- super(Node.SIMPLE_KEYWORD, value);
- }
-
- protected SimpleKeywordNode(int type, Object value) {
- super(type, value);
- }
-
- public List<String> getOptions() {
- return optionList;
- }
-
- public void setOptions(List<String> optionList) {
- this.optionList = optionList;
- }
-
- public boolean equals(Object o) {
- // System.out.println("Keyword.equals()");
- if (!super.equals(o)) {
- return false;
- }
-
- if (!(o instanceof SimpleKeywordNode)) {
- return false;
- }
- SimpleKeywordNode r = (SimpleKeywordNode) o;
-
- return (optionList != null ? optionList.equals(r.optionList)
- : r.optionList == null);
- }
-
- public String toString() {
- StringBuffer buf = new StringBuffer();
- if (optionList == null) {
- buf.append("KeyWord(" + value + "," + formatInfo + ")");
- } else {
- buf.append("KeyWord(" + value + ", " + formatInfo + "," + optionList
- + ")");
- }
- buf.append(printNext());
- return buf.toString();
- }
-}
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.pattern.parser;
+
+import java.util.List;
+
+public class SimpleKeywordNode extends FormattingNode {
+
+ List<String> optionList;
+
+ SimpleKeywordNode(Object value) {
+ super(Node.SIMPLE_KEYWORD, value);
+ }
+
+ protected SimpleKeywordNode(int type, Object value) {
+ super(type, value);
+ }
+
+ public List<String> getOptions() {
+ return optionList;
+ }
+
+ public void setOptions(List<String> optionList) {
+ this.optionList = optionList;
+ }
+
+ public boolean equals(Object o) {
+ // System.out.println("Keyword.equals()");
+ if (!super.equals(o)) {
+ return false;
+ }
+
+ if (!(o instanceof SimpleKeywordNode)) {
+ return false;
+ }
+ SimpleKeywordNode r = (SimpleKeywordNode) o;
+
+ return (optionList != null ? optionList.equals(r.optionList)
+ : r.optionList == null);
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ if (optionList == null) {
+ buf.append("KeyWord(" + value + "," + formatInfo + ")");
+ } else {
+ buf.append("KeyWord(" + value + ", " + formatInfo + "," + optionList
+ + ")");
+ }
+ buf.append(printNext());
+ return buf.toString();
+ }
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/property/FileExistsPropertyDefiner.java b/logback-core/src/main/java/ch/qos/logback/core/property/FileExistsPropertyDefiner.java
index 89b16e7..2f108ee 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/property/FileExistsPropertyDefiner.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/property/FileExistsPropertyDefiner.java
@@ -1,31 +1,31 @@
-package ch.qos.logback.core.property;
-
-import ch.qos.logback.core.PropertyDefinerBase;
-import java.io.File;
-
-/**
- * @author Ceki Gücü
- */
-public class FileExistsPropertyDefiner extends PropertyDefinerBase {
-
- String path;
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public String getPropertyValue() {
- if(path == null)
- return "false";
- File file = new File(path);
- System.out.println(file.getAbsolutePath());
- if(file.exists())
- return "true";
- else
- return "false";
- }
-}
+package ch.qos.logback.core.property;
+
+import ch.qos.logback.core.PropertyDefinerBase;
+import java.io.File;
+
+/**
+ * @author Ceki Gücü
+ */
+public class FileExistsPropertyDefiner extends PropertyDefinerBase {
+
+ String path;
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getPropertyValue() {
+ if(path == null)
+ return "false";
+ File file = new File(path);
+ System.out.println(file.getAbsolutePath());
+ if(file.exists())
+ return "true";
+ else
+ return "false";
+ }
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/StatusChecker.java b/logback-core/src/main/java/ch/qos/logback/core/status/StatusChecker.java
index 18f81cc..d9e3d2c 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/status/StatusChecker.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/status/StatusChecker.java
@@ -1,119 +1,119 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.core.status;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import ch.qos.logback.core.Context;
-import ch.qos.logback.core.CoreConstants;
-
-import static ch.qos.logback.core.status.StatusUtil.filterStatusListByTimeThreshold;
-
-public class StatusChecker {
-
- StatusManager sm;
-
- public StatusChecker(StatusManager sm) {
- this.sm = sm;
- }
-
- public StatusChecker(Context context) {
- this.sm = context.getStatusManager();
- }
-
- public boolean hasXMLParsingErrors(long threshold) {
- return containsMatch(threshold, Status.ERROR, CoreConstants.XML_PARSING);
- }
-
- public boolean noXMLParsingErrorsOccurred(long threshold) {
- return !hasXMLParsingErrors(threshold);
- }
-
- public int getHighestLevel(long threshold) {
- List<Status> filteredList = filterStatusListByTimeThreshold(sm.getCopyOfStatusList(), threshold);
- int maxLevel = Status.INFO;
- for (Status s : filteredList) {
- if (s.getLevel() > maxLevel)
- maxLevel = s.getLevel();
- }
- return maxLevel;
- }
-
- public boolean isErrorFree(long threshold) {
- return Status.ERROR > getHighestLevel(threshold);
- }
-
- public boolean containsMatch(long threshold, int level, String regex) {
- List<Status> filteredList = filterStatusListByTimeThreshold(sm.getCopyOfStatusList(), threshold);
- Pattern p = Pattern.compile(regex);
-
- for (Status status : filteredList) {
- if (level != status.getLevel()) {
- continue;
- }
- String msg = status.getMessage();
- Matcher matcher = p.matcher(msg);
- if (matcher.lookingAt()) {
- return true;
- }
- }
- return false;
-
- }
-
- public boolean containsMatch(int level, String regex) {
- return containsMatch(0, level, regex);
- }
-
- public boolean containsMatch(String regex) {
- Pattern p = Pattern.compile(regex);
- for (Status status : sm.getCopyOfStatusList()) {
- String msg = status.getMessage();
- Matcher matcher = p.matcher(msg);
- if (matcher.lookingAt()) {
- return true;
- }
- }
- return false;
- }
-
- public int matchCount(String regex) {
- int count = 0;
- Pattern p = Pattern.compile(regex);
- for (Status status : sm.getCopyOfStatusList()) {
- String msg = status.getMessage();
- Matcher matcher = p.matcher(msg);
- if (matcher.lookingAt()) {
- count++;
- }
- }
- return count;
- }
-
- public boolean containsException(Class exceptionType) {
- Iterator stati = sm.getCopyOfStatusList().iterator();
- while (stati.hasNext()) {
- Status status = (Status) stati.next();
- Throwable t = status.getThrowable();
- if (t != null && t.getClass().getName().equals(exceptionType.getName())) {
- return true;
- }
- }
- return false;
- }
-
-}
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.status;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.CoreConstants;
+
+import static ch.qos.logback.core.status.StatusUtil.filterStatusListByTimeThreshold;
+
+public class StatusChecker {
+
+ StatusManager sm;
+
+ public StatusChecker(StatusManager sm) {
+ this.sm = sm;
+ }
+
+ public StatusChecker(Context context) {
+ this.sm = context.getStatusManager();
+ }
+
+ public boolean hasXMLParsingErrors(long threshold) {
+ return containsMatch(threshold, Status.ERROR, CoreConstants.XML_PARSING);
+ }
+
+ public boolean noXMLParsingErrorsOccurred(long threshold) {
+ return !hasXMLParsingErrors(threshold);
+ }
+
+ public int getHighestLevel(long threshold) {
+ List<Status> filteredList = filterStatusListByTimeThreshold(sm.getCopyOfStatusList(), threshold);
+ int maxLevel = Status.INFO;
+ for (Status s : filteredList) {
+ if (s.getLevel() > maxLevel)
+ maxLevel = s.getLevel();
+ }
+ return maxLevel;
+ }
+
+ public boolean isErrorFree(long threshold) {
+ return Status.ERROR > getHighestLevel(threshold);
+ }
+
+ public boolean containsMatch(long threshold, int level, String regex) {
+ List<Status> filteredList = filterStatusListByTimeThreshold(sm.getCopyOfStatusList(), threshold);
+ Pattern p = Pattern.compile(regex);
+
+ for (Status status : filteredList) {
+ if (level != status.getLevel()) {
+ continue;
+ }
+ String msg = status.getMessage();
+ Matcher matcher = p.matcher(msg);
+ if (matcher.lookingAt()) {
+ return true;
+ }
+ }
+ return false;
+
+ }
+
+ public boolean containsMatch(int level, String regex) {
+ return containsMatch(0, level, regex);
+ }
+
+ public boolean containsMatch(String regex) {
+ Pattern p = Pattern.compile(regex);
+ for (Status status : sm.getCopyOfStatusList()) {
+ String msg = status.getMessage();
+ Matcher matcher = p.matcher(msg);
+ if (matcher.lookingAt()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public int matchCount(String regex) {
+ int count = 0;
+ Pattern p = Pattern.compile(regex);
+ for (Status status : sm.getCopyOfStatusList()) {
+ String msg = status.getMessage();
+ Matcher matcher = p.matcher(msg);
+ if (matcher.lookingAt()) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ public boolean containsException(Class exceptionType) {
+ Iterator stati = sm.getCopyOfStatusList().iterator();
+ while (stati.hasNext()) {
+ Status status = (Status) stati.next();
+ Throwable t = status.getThrowable();
+ if (t != null && t.getClass().getName().equals(exceptionType.getName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/CachingDateFormatter.java b/logback-core/src/main/java/ch/qos/logback/core/util/CachingDateFormatter.java
index 9be9dff..6f00ed4 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/util/CachingDateFormatter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/util/CachingDateFormatter.java
@@ -1,58 +1,58 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.core.util;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * A synchronized implementation of SimpleDateFormat which uses caching internally.
- *
- * @author Ceki Gücü
- * @since 0.9.29
- */
-public class CachingDateFormatter {
-
-
- long lastTimestamp = -1;
- String cachedStr = null;
- final SimpleDateFormat sdf;
-
- public CachingDateFormatter(String pattern) {
- sdf = new SimpleDateFormat(pattern);
- }
-
- public final String format(long now) {
-
- // SimpleDateFormat is not thread safe.
-
- // See also the discussion in http://jira.qos.ch/browse/LBCLASSIC-36
- // DateFormattingThreadedThroughputCalculator and SelectiveDateFormattingRunnable
- // are also note worthy
-
- // The now == lastTimestamp guard minimizes synchronization
- synchronized (this) {
- if (now != lastTimestamp) {
- lastTimestamp = now;
- cachedStr = sdf.format(new Date(now));
- }
- return cachedStr;
- }
- }
-
- public void setTimeZone(TimeZone tz) {
- sdf.setTimeZone(tz);
- }
-}
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.util;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * A synchronized implementation of SimpleDateFormat which uses caching internally.
+ *
+ * @author Ceki Gücü
+ * @since 0.9.29
+ */
+public class CachingDateFormatter {
+
+
+ long lastTimestamp = -1;
+ String cachedStr = null;
+ final SimpleDateFormat sdf;
+
+ public CachingDateFormatter(String pattern) {
+ sdf = new SimpleDateFormat(pattern);
+ }
+
+ public final String format(long now) {
+
+ // SimpleDateFormat is not thread safe.
+
+ // See also the discussion in http://jira.qos.ch/browse/LBCLASSIC-36
+ // DateFormattingThreadedThroughputCalculator and SelectiveDateFormattingRunnable
+ // are also note worthy
+
+ // The now == lastTimestamp guard minimizes synchronization
+ synchronized (this) {
+ if (now != lastTimestamp) {
+ lastTimestamp = now;
+ cachedStr = sdf.format(new Date(now));
+ }
+ return cachedStr;
+ }
+ }
+
+ public void setTimeZone(TimeZone tz) {
+ sdf.setTimeZone(tz);
+ }
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java
index 5cd7812..ec708aa 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java
@@ -1,42 +1,42 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.core.util;
-
-/**
- * @author Ceki Gücü
- */
-public class EnvUtil {
-
-
- static public boolean isGroovyAvailable() {
- ClassLoader classLoader = EnvUtil.class.getClassLoader();
- try {
- Class bindingClass = classLoader.loadClass("groovy.lang.Binding");
- return (bindingClass != null);
- } catch (ClassNotFoundException e) {
- return false;
- }
- }
-
-
- static public boolean isJaninoAvailable() {
- ClassLoader classLoader = EnvUtil.class.getClassLoader();
- try {
- Class bindingClass = classLoader.loadClass("org.codehaus.janino.Cookable");
- return (bindingClass != null);
- } catch (ClassNotFoundException e) {
- return false;
- }
- }
-}
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.util;
+
+/**
+ * @author Ceki Gücü
+ */
+public class EnvUtil {
+
+
+ static public boolean isGroovyAvailable() {
+ ClassLoader classLoader = EnvUtil.class.getClassLoader();
+ try {
+ Class bindingClass = classLoader.loadClass("groovy.lang.Binding");
+ return (bindingClass != null);
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+
+
+ static public boolean isJaninoAvailable() {
+ ClassLoader classLoader = EnvUtil.class.getClassLoader();
+ try {
+ Class bindingClass = classLoader.loadClass("org.codehaus.janino.Cookable");
+ return (bindingClass != null);
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+}
-----------------------------------------------------------------------
Summary of changes:
.../core/pattern/parser/SimpleKeywordNode.java | 128 ++++++------
.../core/property/FileExistsPropertyDefiner.java | 62 +++---
.../ch/qos/logback/core/status/StatusChecker.java | 238 ++++++++++----------
.../logback/core/util/CachingDateFormatter.java | 116 +++++-----
.../java/ch/qos/logback/core/util/EnvUtil.java | 84 ++++----
5 files changed, 314 insertions(+), 314 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-46-gdea82f9
by git-noreply@pixie.qos.ch 25 Oct '11
by git-noreply@pixie.qos.ch 25 Oct '11
25 Oct '11
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 dea82f92852be5f4c191ebb06ff5c8254485428b (commit)
from 3634bf15c5c1eaf35699770b858ab0b29fc4fc97 (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=dea82f92852be5f4c191ebb0…
http://github.com/ceki/logback/commit/dea82f92852be5f4c191ebb06ff5c82544854…
commit dea82f92852be5f4c191ebb06ff5c8254485428b
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Tue Oct 25 22:07:13 2011 +0200
make ReconfigureOnChangeTest more robust
diff --git a/logback-classic/src/test/input/joran/scan1.xml b/logback-classic/src/test/input/joran/scan1.xml
index 68c4af3..7be1d6c 100644
--- a/logback-classic/src/test/input/joran/scan1.xml
+++ b/logback-classic/src/test/input/joran/scan1.xml
@@ -1,16 +1,9 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE configuration>
-
<configuration scan="true" scanPeriod="1 millisecond">
- <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>yx %d - %m%n"</Pattern>
- </encoder>
- </appender>
+ <appender name="LIST" class="ch.qos.logback.core.read.ListAppender"/>
<root level="TRACE">
- <appender-ref ref="CONSOLE" />
+ <appender-ref ref="LIST" />
</root>
</configuration>
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderIntegrationTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderIntegrationTest.java
index aa72ae5..245ae90 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderIntegrationTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderIntegrationTest.java
@@ -48,8 +48,8 @@ public class DBAppenderIntegrationTest {
static String LOCAL_HOST_NAME;
static String[] CONFORMING_HOST_LIST = new String[] { "Orion" };
static String[] POSTGRES_CONFORMING_HOST_LIST = new String[] { "haro" };
- static String[] MYSQL_CONFORMING_HOST_LIST = new String[] { "hetz", "haro" };
- static String[] ORACLE_CONFORMING_HOST_LIST = new String[] { "haro" };
+ static String[] MYSQL_CONFORMING_HOST_LIST = new String[] { "hetz", "xharo" };
+ static String[] ORACLE_CONFORMING_HOST_LIST = new String[] { "xharo" };
int diff = RandomUtil.getPositiveInt();
LoggerContext lc = new LoggerContext();
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 3f8f5a2..188b222 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
@@ -287,7 +287,7 @@ public class JoranConfiguratorTest {
// Tests whether ConfigurationAction is installing ReconfigureOnChangeFilter
@Test
- public void scan1() throws JoranException, IOException, InterruptedException {
+ public void autoscanShouldReconfigureOnFileChange() throws Exception {
String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
+ "scan1.xml";
@@ -296,7 +296,7 @@ public class JoranConfiguratorTest {
File file = new File(configFileAsStr);
file.setLastModified(System.currentTimeMillis());
- Thread.sleep(100);
+ Thread.sleep(10);
// scanning requires 16 logs
for (int i = 0; i < 16; i++) {
logger.debug("after " + i);
@@ -305,7 +305,7 @@ public class JoranConfiguratorTest {
loggerContext.getExecutorService().shutdown();
loggerContext.getExecutorService().awaitTermination(1000, TimeUnit.MILLISECONDS);
- StatusPrinter.print(loggerContext);
+ //StatusPrinter.print(loggerContext);
StatusChecker checker = new StatusChecker(loggerContext);
assertTrue(checker.isErrorFree(0));
assertTrue(checker.containsMatch("Will reset and reconfigure context"));
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java
index 446fafb..c59d364 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java
@@ -122,8 +122,9 @@ public class SMTPAppender_SubethaSMTPTest {
}
void waitUntilEmailIsSent() throws Exception {
+ System.out.println("About to wait for sending thread to finish");
loggerContext.getExecutorService().shutdown();
- loggerContext.getExecutorService().awaitTermination(1000, TimeUnit.MILLISECONDS);
+ loggerContext.getExecutorService().awaitTermination(3000, TimeUnit.MILLISECONDS);
}
private static String getBody(Part msg) {
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
index fd3247f..b63a079 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
@@ -19,14 +19,18 @@ import static org.junit.Assert.assertTrue;
import java.io.*;
import java.net.MalformedURLException;
-import java.util.Random;
+import java.util.concurrent.ThreadPoolExecutor;
import ch.qos.logback.classic.gaffer.GafferConfigurator;
+import ch.qos.logback.core.contention.AbstractMultiThreadedHarness;
+import ch.qos.logback.core.contention.MultiThreadedHarness;
+import ch.qos.logback.core.contention.WaitOnExecutionMultiThreadedHarness;
import ch.qos.logback.core.joran.util.ConfigurationWatchListUtil;
import ch.qos.logback.core.testUtil.RandomUtil;
import ch.qos.logback.core.util.CoreTestConstants;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.helpers.BogoPerf;
@@ -37,7 +41,6 @@ import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.issue.lbclassic135.LoggingRunnable;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.CoreConstants;
-import ch.qos.logback.core.contention.MultiThreadedHarness;
import ch.qos.logback.core.contention.RunnableWithCounterAndDone;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.status.InfoStatus;
@@ -52,6 +55,9 @@ public class ReconfigureOnChangeTest {
static final boolean MUST_BE_ERROR_FREE = true;
static final boolean ERRORS_EXPECTED = false;
+ static final boolean REGULAR_RECONFIGURATION = false;
+ static final boolean FORCED_RECONFIGURATION_SKIP = true;
+
int diff = RandomUtil.getPositiveInt();
@@ -87,32 +93,27 @@ public class ReconfigureOnChangeTest {
// it actually takes time for Windows to propagate file modification changes
// values below 100 milliseconds can be problematic the same propagation
// latency occurs in Linux but is even larger (>600 ms)
- final static int DEFAULT_SLEEP_BETWEEN_UPDATES = 210;
+ final static int DEFAULT_SLEEP_BETWEEN_UPDATES = 60;
- int sleepBetweenUpdates = DEFAULT_SLEEP_BETWEEN_UPDATES;
+ int sleepBetweenUpdates = 100;//DEFAULT_SLEEP_BETWEEN_UPDATES;
- static int totalTestDuration;
+// static int totalTestDuration;
LoggerContext loggerContext = new LoggerContext();
Logger logger = loggerContext.getLogger(this.getClass());
- MultiThreadedHarness harness;
+ AbstractMultiThreadedHarness harness;
+
+ ThreadPoolExecutor executor = (ThreadPoolExecutor) loggerContext.getExecutorService();
+
+ int expectedResets = 2;
@Before
public void setUp() {
- System.out.println("======== TEST START, time" + System.currentTimeMillis());
- // take into account propagation latency occurs on Linux or Mac
- if (Env.isLinux() || Env.isMac()) {
- sleepBetweenUpdates = 950;
- totalTestDuration = sleepBetweenUpdates * 5;
- } else {
- totalTestDuration = sleepBetweenUpdates * 10;
- }
- harness = new MultiThreadedHarness(totalTestDuration);
+ harness = new WaitOnExecutionMultiThreadedHarness(executor, expectedResets);
}
@After
public void tearDown() {
- System.out.println("======= TEST STOP");
}
void configure(File file) throws JoranException {
@@ -143,7 +144,7 @@ public class ReconfigureOnChangeTest {
void doScanTest(File fileToTouch) throws JoranException, IOException, InterruptedException {
- doScanTest(fileToTouch, UpdateType.TOUCH, false, MUST_BE_ERROR_FREE);
+ doScanTest(fileToTouch, UpdateType.TOUCH, REGULAR_RECONFIGURATION, MUST_BE_ERROR_FREE);
}
void doScanTest(File fileToTouch, UpdateType updateType, boolean forcedReconfigurationSkip, boolean mustBeErrorFree) throws JoranException, IOException, InterruptedException {
@@ -153,22 +154,22 @@ public class ReconfigureOnChangeTest {
loggerContext.getStatusManager().add(
new InfoStatus("end of execution ", this));
- long expectedReconfigurations = runnableArray[0].getCounter();
+ int expected = expectedResets;
if (forcedReconfigurationSkip)
- expectedReconfigurations = 0;
+ expected = 0;
- verify(expectedReconfigurations, mustBeErrorFree);
+ verify(expected, mustBeErrorFree);
}
// Tests whether ConfigurationAction is installing ReconfigureOnChangeFilter
- @Test
+ @Test(timeout = 4000L)
public void scan1() throws JoranException, IOException, InterruptedException {
File file = new File(SCAN1_FILE_AS_STR);
configure(file);
doScanTest(file);
}
- @Test
+ @Test(timeout = 4000L)
public void scanWithFileInclusion() throws JoranException, IOException, InterruptedException {
File topLevelFile = new File(INCLUSION_SCAN_TOPLEVEL0_AS_STR);
File innerFile = new File(INCLUSION_SCAN_INNER0_AS_STR);
@@ -176,7 +177,7 @@ public class ReconfigureOnChangeTest {
doScanTest(innerFile);
}
- @Test
+ @Test(timeout = 4000L)
public void scanWithResourceInclusion() throws JoranException, IOException, InterruptedException {
File topLevelFile = new File(INCLUSION_SCAN_TOP_BY_RESOURCE_AS_STR);
File innerFile = new File(INCLUSION_SCAN_INNER1_AS_STR);
@@ -185,24 +186,25 @@ public class ReconfigureOnChangeTest {
}
// See also http://jira.qos.ch/browse/LBCLASSIC-247
- @Test
+ @Test(timeout = 4000L)
public void includeScanViaInputStreamSuppliedConfigFile() throws IOException, JoranException, InterruptedException {
+ harness = new MultiThreadedHarness(1000);
String configurationStr = "<configuration scan=\"true\" scanPeriod=\"50 millisecond\"><include resource=\"asResource/inner1.xml\"/></configuration>";
configure(new ByteArrayInputStream(configurationStr.getBytes("UTF-8")));
File innerFile = new File(INCLUSION_SCAN_INNER1_AS_STR);
- doScanTest(innerFile, UpdateType.TOUCH, true, MUST_BE_ERROR_FREE);
+ doScanTest(innerFile, UpdateType.TOUCH, FORCED_RECONFIGURATION_SKIP, MUST_BE_ERROR_FREE);
}
- @Test
+ @Test(timeout = 4000L)
public void fallbackToSafe() throws IOException, JoranException, InterruptedException {
String path = CoreTestConstants.OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_fallbackToSafe-" + diff + ".xml";
File file = new File(path);
writeToFile(file, "<configuration scan=\"true\" scanPeriod=\"50 millisecond\"><root level=\"ERROR\"/></configuration> ");
configure(file);
- doScanTest(file, UpdateType.MALFORMED, false, ERRORS_EXPECTED);
+ doScanTest(file, UpdateType.MALFORMED, REGULAR_RECONFIGURATION, ERRORS_EXPECTED);
}
- @Test
+ @Test(timeout = 4000L)
public void fallbackToSafeWithIncludedFile() throws IOException, JoranException, InterruptedException {
String topLevelFileAsStr = CoreTestConstants.OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_top-" + diff + ".xml";
String innerFileAsStr = CoreTestConstants.OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_inner-" + diff + ".xml";
@@ -212,11 +214,11 @@ public class ReconfigureOnChangeTest {
File innerFile = new File(innerFileAsStr);
writeToFile(innerFile, "<included><root level=\"ERROR\"/></included> ");
configure(topLevelFile);
- doScanTest(innerFile, UpdateType.MALFORMED_INNER, false, ERRORS_EXPECTED);
+ doScanTest(innerFile, UpdateType.MALFORMED_INNER, REGULAR_RECONFIGURATION, ERRORS_EXPECTED);
}
- @Test
+ @Test(timeout = 4000L)
public void gscan1() throws JoranException, IOException, InterruptedException {
File file = new File(G_SCAN1_FILE_AS_STR);
gConfigure(file);
@@ -226,13 +228,11 @@ public class ReconfigureOnChangeTest {
loggerContext.getStatusManager().add(
new InfoStatus("end of execution ", this));
- long expectedRreconfigurations = runnableArray[0].getCounter();
- verify(expectedRreconfigurations, MUST_BE_ERROR_FREE);
+ verify(expectedResets, MUST_BE_ERROR_FREE);
}
// check for deadlocks
- //Attr_Test(timeout = 20000)
- @Test
+ @Test(timeout = 4000L)
public void scan_lbclassic154() throws JoranException, IOException,
InterruptedException {
File file = new File(SCAN_LBCLASSIC_154_FILE_AS_STR);
@@ -243,12 +243,11 @@ public class ReconfigureOnChangeTest {
loggerContext.getStatusManager().add(
new InfoStatus("end of execution ", this));
- long expectedReconfigurations = runnableArray[0].getCounter();
- verify(expectedReconfigurations, MUST_BE_ERROR_FREE);
+ verify(expectedResets, MUST_BE_ERROR_FREE);
}
- void verify(long expectedReconfigurations, boolean errorFreeness) {
+ void verify(int expected, boolean errorFreeness) {
StatusChecker checker = new StatusChecker(loggerContext);
StatusPrinter.print(loggerContext);
if (errorFreeness == MUST_BE_ERROR_FREE) {
@@ -256,23 +255,14 @@ public class ReconfigureOnChangeTest {
} else {
assertFalse(checker.isErrorFree(0));
}
+
int effectiveResets = checker
.matchCount("Will reset and reconfigure context");
- // the number of effective resets must be equal or less than
- // expectedReconfigurations
- System.out.println("effectiveResets=" + effectiveResets);
-
- System.out.println("expectedReconfigurations=" + expectedReconfigurations);
- assertTrue(effectiveResets <= expectedReconfigurations);
- // however, there should be some effective resets
String failMsg = "effective=" + effectiveResets + ", expected="
- + expectedReconfigurations;
- // we can't have the test succeed under JDK 1.5, punt and require 1.6+
- if (Env.isJDK6OrHigher()) {
- assertTrue(failMsg,
- (effectiveResets * 1.5) >= (expectedReconfigurations * 1.0));
- }
+ + expected;
+ assertEquals(failMsg, expected, effectiveResets);
+
}
ReconfigureOnChangeFilter initROCF() throws MalformedURLException {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java b/logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java
new file mode 100644
index 0000000..aa4d4fd
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java
@@ -0,0 +1,29 @@
+package ch.qos.logback.core.contention;
+
+abstract public class AbstractMultiThreadedHarness {
+
+ RunnableWithCounterAndDone[] runnableArray;
+
+ abstract void waitUntilEndCondition() throws InterruptedException;
+
+ public void execute(RunnableWithCounterAndDone[] runnableArray)
+ throws InterruptedException {
+ this.runnableArray = runnableArray;
+ Thread[] threadArray = new Thread[runnableArray.length];
+
+ for (int i = 0; i < runnableArray.length; i++) {
+ threadArray[i] = new Thread(runnableArray[i], "Harness["+i+"]");
+ }
+ for (Thread t : threadArray) {
+ t.start();
+ }
+
+ waitUntilEndCondition();
+ for (RunnableWithCounterAndDone r : runnableArray) {
+ r.setDone(true);
+ }
+ for (Thread t : threadArray) {
+ t.join();
+ }
+ }
+}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java b/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java
index 093f889..8b9f744 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/contention/MultiThreadedHarness.java
@@ -21,10 +21,8 @@ package ch.qos.logback.core.contention;
* @author Ralph Goers
* @author Ceki Gulcu
*/
-public class MultiThreadedHarness {
+public class MultiThreadedHarness extends AbstractMultiThreadedHarness {
- RunnableWithCounterAndDone[] runnableArray;
- Thread[] threadArray;
final long overallDurationInMillis;
public MultiThreadedHarness(long overallDurationInMillis) {
@@ -45,25 +43,7 @@ public class MultiThreadedHarness {
+ System.getProperty("os.version"));
}
- public void execute(RunnableWithCounterAndDone[] runnableArray)
- throws InterruptedException {
- this.runnableArray = runnableArray;
- Thread[] threadArray = new Thread[runnableArray.length];
-
- for (int i = 0; i < runnableArray.length; i++) {
- threadArray[i] = new Thread(runnableArray[i], "Harness["+i+"]");
- }
- for (Thread t : threadArray) {
- t.start();
- }
- // let the threads run for a while
+ void waitUntilEndCondition() throws InterruptedException {
Thread.sleep(overallDurationInMillis);
-
- for (RunnableWithCounterAndDone r : runnableArray) {
- r.setDone(true);
- }
- for (Thread t : threadArray) {
- t.join();
- }
}
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java b/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java
new file mode 100644
index 0000000..0854e7a
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java
@@ -0,0 +1,20 @@
+package ch.qos.logback.core.contention;
+
+import java.util.concurrent.ThreadPoolExecutor;
+
+public class WaitOnExecutionMultiThreadedHarness extends AbstractMultiThreadedHarness {
+ ThreadPoolExecutor threadPoolExecutor;
+ int count;
+
+ public WaitOnExecutionMultiThreadedHarness(ThreadPoolExecutor threadPoolExecutor, int count) {
+ this.threadPoolExecutor = threadPoolExecutor;
+ this.count =count;
+
+ }
+ @Override
+ void waitUntilEndCondition() throws InterruptedException {
+ while(threadPoolExecutor.getCompletedTaskCount() != count) {
+ Thread.sleep(100);
+ }
+ }
+}
-----------------------------------------------------------------------
Summary of changes:
logback-classic/src/test/input/joran/scan1.xml | 11 +--
.../classic/db/DBAppenderIntegrationTest.java | 4 +-
.../classic/joran/JoranConfiguratorTest.java | 6 +-
.../classic/net/SMTPAppender_SubethaSMTPTest.java | 3 +-
.../classic/turbo/ReconfigureOnChangeTest.java | 90 +++++++++-----------
.../contention/AbstractMultiThreadedHarness.java | 29 ++++++
.../core/contention/MultiThreadedHarness.java | 24 +-----
.../WaitOnExecutionMultiThreadedHarness.java | 20 +++++
8 files changed, 100 insertions(+), 87 deletions(-)
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/contention/AbstractMultiThreadedHarness.java
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/contention/WaitOnExecutionMultiThreadedHarness.java
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-45-g3634bf1
by git-noreply@pixie.qos.ch 25 Oct '11
by git-noreply@pixie.qos.ch 25 Oct '11
25 Oct '11
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 3634bf15c5c1eaf35699770b858ab0b29fc4fc97 (commit)
from 3c8be08f247f5d7ca4db1c809eefca9d7f1e8c31 (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=3634bf15c5c1eaf35699770b…
http://github.com/ceki/logback/commit/3634bf15c5c1eaf35699770b858ab0b29fc4f…
commit 3634bf15c5c1eaf35699770b858ab0b29fc4fc97
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Tue Oct 25 20:56:28 2011 +0200
make scan1 test in JoranConfiguratorTest more robust
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 1e345a2..3f8f5a2 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
@@ -17,6 +17,7 @@ import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.concurrent.TimeUnit;
import java.util.logging.LogManager;
import ch.qos.logback.classic.jul.JULHelper;
@@ -45,6 +46,7 @@ import ch.qos.logback.core.read.ListAppender;
import ch.qos.logback.core.status.StatusChecker;
import ch.qos.logback.core.testUtil.StringListAppender;
+
import static org.junit.Assert.*;
public class JoranConfiguratorTest {
@@ -300,6 +302,9 @@ public class JoranConfiguratorTest {
logger.debug("after " + i);
}
+ loggerContext.getExecutorService().shutdown();
+ loggerContext.getExecutorService().awaitTermination(1000, TimeUnit.MILLISECONDS);
+
StatusPrinter.print(loggerContext);
StatusChecker checker = new StatusChecker(loggerContext);
assertTrue(checker.isErrorFree(0));
diff --git a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
index 4d74c3f..88d4de9 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
@@ -77,7 +77,7 @@ public class FileAppenderResilienceTest {
t.start();
double delayCoefficient = 2.0;
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < 5; i++) {
Thread.sleep((int)(RecoveryCoordinator.BACKOFF_COEFFICIENT_MIN * delayCoefficient));
closeLogFileOnPurpose();
}
@@ -85,7 +85,7 @@ public class FileAppenderResilienceTest {
t.join();
double bestCaseSuccessRatio = 1/delayCoefficient;
- double lossinessFactor = 0.5;
+ double lossinessFactor = 0.8;
ResilienceUtil
.verify(logfileStr, "^hello (\\d{1,5})$", runner.getCounter(), bestCaseSuccessRatio * lossinessFactor);
}
@@ -109,7 +109,7 @@ class Runner extends RunnableWithCounterAndDone {
while (!isDone()) {
counter++;
fa.doAppend("hello " + counter);
- if (counter % 512 == 0) {
+ if (counter % 128 == 0) {
try { Thread.sleep(10);
} catch (InterruptedException e) { }
}
-----------------------------------------------------------------------
Summary of changes:
.../classic/joran/JoranConfiguratorTest.java | 5 +++++
.../logback/core/FileAppenderResilienceTest.java | 6 +++---
2 files changed, 8 insertions(+), 3 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-44-g3c8be08
by git-noreply@pixie.qos.ch 25 Oct '11
by git-noreply@pixie.qos.ch 25 Oct '11
25 Oct '11
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 3c8be08f247f5d7ca4db1c809eefca9d7f1e8c31 (commit)
from e3e03a7dc7882acb47d724f4a53853ac1dfb3abf (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=3c8be08f247f5d7ca4db1c80…
http://github.com/ceki/logback/commit/3c8be08f247f5d7ca4db1c809eefca9d7f1e8…
commit 3c8be08f247f5d7ca4db1c809eefca9d7f1e8c31
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Tue Oct 25 20:48:24 2011 +0200
make FileAppenderResilienceTest less picky
diff --git a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
index 0cc7a2c..4d74c3f 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
@@ -76,20 +76,25 @@ public class FileAppenderResilienceTest {
Thread t = new Thread(runner);
t.start();
- double delayCoeff = 2.0;
- for (int i = 0; i < 5; i++) {
- Thread.sleep((int)(RecoveryCoordinator.BACKOFF_COEFFICIENT_MIN * delayCoeff));
- ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) fa
- .getOutputStream();
- FileChannel fileChannel = resilientFOS.getChannel();
- fileChannel.close();
+ double delayCoefficient = 2.0;
+ for (int i = 0; i < 3; i++) {
+ Thread.sleep((int)(RecoveryCoordinator.BACKOFF_COEFFICIENT_MIN * delayCoefficient));
+ closeLogFileOnPurpose();
}
runner.setDone(true);
t.join();
- double bestCaseSuccessRatio = 1/delayCoeff;
+ double bestCaseSuccessRatio = 1/delayCoefficient;
+ double lossinessFactor = 0.5;
ResilienceUtil
- .verify(logfileStr, "^hello (\\d{1,5})$", runner.getCounter(), bestCaseSuccessRatio*0.8);
+ .verify(logfileStr, "^hello (\\d{1,5})$", runner.getCounter(), bestCaseSuccessRatio * lossinessFactor);
+ }
+
+ private void closeLogFileOnPurpose() throws IOException {
+ ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) fa
+ .getOutputStream();
+ FileChannel fileChannel = resilientFOS.getChannel();
+ fileChannel.close();
}
}
-----------------------------------------------------------------------
Summary of changes:
.../logback/core/FileAppenderResilienceTest.java | 23 ++++++++++++-------
1 files changed, 14 insertions(+), 9 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-43-ge3e03a7
by git-noreply@pixie.qos.ch 25 Oct '11
by git-noreply@pixie.qos.ch 25 Oct '11
25 Oct '11
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 e3e03a7dc7882acb47d724f4a53853ac1dfb3abf (commit)
from 4fadcb4ae7e8bac392524a37e9ab1a3a8159b6fe (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=e3e03a7dc7882acb47d724f4…
http://github.com/ceki/logback/commit/e3e03a7dc7882acb47d724f4a53853ac1dfb3…
commit e3e03a7dc7882acb47d724f4a53853ac1dfb3abf
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Tue Oct 25 20:31:47 2011 +0200
Context now offers an execution service
diff --git a/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java b/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
index e1a6edc..20e17c7 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
@@ -19,6 +19,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.*;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -86,6 +87,11 @@ public class LogbackValve extends ValveBase implements Lifecycle, Context,
boolean started;
boolean alreadySetLogbackStatusManager = false;
+ // 0 idle threads, 2 maximum threads, no idle waiting
+ ExecutorService executorService = new ThreadPoolExecutor(0, 2,
+ 0L, TimeUnit.MILLISECONDS,
+ new LinkedBlockingQueue<Runnable>());
+
public LogbackValve() {
putObject(CoreConstants.EVALUATOR_MAP, new HashMap());
}
@@ -262,6 +268,10 @@ public class LogbackValve extends ValveBase implements Lifecycle, Context,
return fai.getFilterChainDecision(event);
}
+ public ExecutorService getExecutorService() {
+ return executorService;
+ }
+
public String getName() {
return name;
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
index 9ffa390..3565e60 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
@@ -122,7 +122,7 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
// reader lock.
private void detachReconfigurationToNewThread() {
addInfo("Detected change in [" + configurationWatchList.getCopyOfFileWatchList() + "]");
- new ReconfiguringThread().start();
+ context.getExecutorService().submit(new ReconfiguringThread());
}
void updateNextCheck(long now) {
@@ -150,7 +150,7 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
this.refreshPeriod = refreshPeriod;
}
- class ReconfiguringThread extends Thread {
+ class ReconfiguringThread implements Runnable {
public void run() {
if (mainConfigurationURL == null) {
addInfo("Due to missing top level configuration file, skipping reconfiguration");
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java
index 0f39071..0fdf203 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java
@@ -18,6 +18,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
@@ -118,6 +119,10 @@ public class SMTPAppender_GreenTest {
return (MimeMultipart) mm.getContent();
}
+ void waitUntilEmailIsSent() throws InterruptedException {
+ lc.getExecutorService().shutdown();
+ lc.getExecutorService().awaitTermination(1000, TimeUnit.MILLISECONDS);
+ }
@Test
public void smoke() throws Exception {
buildSMTPAppender();
@@ -127,6 +132,11 @@ public class SMTPAppender_GreenTest {
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
+ waitUntilEmailIsSent();
+// synchronized (smtpAppender) {
+// smtpAppender.wait();
+// }
+
StatusPrinter.print(lc);
MimeMultipart mp = verify(TEST_SUBJECT);
String body = GreenMailUtil.getBody(mp.getBodyPart(0));
@@ -145,6 +155,7 @@ public class SMTPAppender_GreenTest {
MDC.clear();
logger.error("en error", new Exception("an exception"));
+ waitUntilEmailIsSent();
MimeMultipart mp = verify(TEST_SUBJECT);
String body = GreenMailUtil.getBody(mp.getBodyPart(0));
assertTrue(body.startsWith(HEADER.trim()));
@@ -160,6 +171,8 @@ public class SMTPAppender_GreenTest {
logger.addAppender(smtpAppender);
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
+
+ waitUntilEmailIsSent();
MimeMultipart mp = verify(TEST_SUBJECT);
// verify strict adherence to xhtml1-strict.dtd
@@ -188,6 +201,7 @@ public class SMTPAppender_GreenTest {
}
logger.error("en error", new Exception("an exception"));
+ waitUntilEmailIsSent();
MimeMultipart mp = verify(TEST_SUBJECT);
// verify strict adherence to xhtml1-strict.dtd
@@ -214,6 +228,7 @@ public class SMTPAppender_GreenTest {
String msg2 = "world";
logger.debug(msg2);
logger.debug("invisible");
+ waitUntilEmailIsSent();
MimeMultipart mp = verify(this.getClass().getName() + " - " + msg2);
String body = GreenMailUtil.getBody(mp.getBodyPart(0));
assertEquals("helloworld", body);
@@ -228,6 +243,7 @@ public class SMTPAppender_GreenTest {
logger.debug("invisible2");
String msg = "hello";
logger.error(msg);
+ waitUntilEmailIsSent();
MimeMultipart mp = verify(this.getClass().getName() + " - " + msg);
String body = GreenMailUtil.getBody(mp.getBodyPart(0));
assertEquals(msg, body);
@@ -243,8 +259,7 @@ public class SMTPAppender_GreenTest {
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
- StatusPrinter.print(lc);
-
+ waitUntilEmailIsSent();
MimeMessage[] mma = greenMail.getReceivedMessages();
assertNotNull(mma);
assertEquals(3, mma.length);
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java
index 13b9604..446fafb 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_SubethaSMTPTest.java
@@ -20,6 +20,8 @@ import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.Random;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import javax.mail.Part;
import javax.mail.internet.MimeMessage;
@@ -57,7 +59,7 @@ public class SMTPAppender_SubethaSMTPTest {
Wiser wiser;
SMTPAppender smtpAppender;
- LoggerContext lc = new LoggerContext();
+ LoggerContext loggerContext = new LoggerContext();
static final String TEST_SUBJECT = "test subject";
static final String HEADER = "HEADER\n";
@@ -75,7 +77,7 @@ public class SMTPAppender_SubethaSMTPTest {
void buildSMTPAppender() throws Exception {
smtpAppender = new SMTPAppender();
- smtpAppender.setContext(lc);
+ smtpAppender.setContext(loggerContext);
smtpAppender.setName("smtp");
smtpAppender.setFrom("user(a)host.dom");
smtpAppender.setSMTPHost("localhost");
@@ -118,7 +120,12 @@ public class SMTPAppender_SubethaSMTPTest {
throw new RuntimeException(e);
}
}
-
+
+ void waitUntilEmailIsSent() throws Exception {
+ loggerContext.getExecutorService().shutdown();
+ loggerContext.getExecutorService().awaitTermination(1000, TimeUnit.MILLISECONDS);
+ }
+
private static String getBody(Part msg) {
String all = getWholeMessage(msg);
int i = all.indexOf("\r\n\r\n");
@@ -127,12 +134,15 @@ public class SMTPAppender_SubethaSMTPTest {
@Test
public void smoke() throws Exception {
- smtpAppender.setLayout(buildPatternLayout(lc));
+ smtpAppender.setLayout(buildPatternLayout(loggerContext));
smtpAppender.start();
- Logger logger = lc.getLogger("test");
+ Logger logger = loggerContext.getLogger("test");
logger.addAppender(smtpAppender);
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
+
+ waitUntilEmailIsSent();
+ System.out.println("*** "+((ThreadPoolExecutor)loggerContext.getExecutorService()).getCompletedTaskCount());
List<WiserMessage> wiserMsgList = wiser.getMessages();
assertNotNull(wiserMsgList);
@@ -151,13 +161,13 @@ public class SMTPAppender_SubethaSMTPTest {
@Test
public void html() throws Exception {
- smtpAppender.setLayout(buildHTMLLayout(lc));
+ smtpAppender.setLayout(buildHTMLLayout(loggerContext));
smtpAppender.start();
- Logger logger = lc.getLogger("test");
+ Logger logger = loggerContext.getLogger("test");
logger.addAppender(smtpAppender);
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
-
+ waitUntilEmailIsSent();
List<WiserMessage> wiserMsgList = wiser.getMessages();
assertNotNull(wiserMsgList);
@@ -185,14 +195,15 @@ public class SMTPAppender_SubethaSMTPTest {
* the generated output will be rather short.
*/
public void htmlLong() throws Exception {
- smtpAppender.setLayout(buildHTMLLayout(lc));
+ smtpAppender.setLayout(buildHTMLLayout(loggerContext));
smtpAppender.start();
- Logger logger = lc.getLogger("test");
+ Logger logger = loggerContext.getLogger("test");
logger.addAppender(smtpAppender);
for (int i = 0; i < CoreConstants.TABLE_ROW_LIMIT * 3; i++) {
logger.debug("hello " + i);
}
logger.error("en error", new Exception("an exception"));
+ waitUntilEmailIsSent();
List<WiserMessage> wiserMsgList = wiser.getMessages();
assertNotNull(wiserMsgList);
@@ -218,13 +229,13 @@ public class SMTPAppender_SubethaSMTPTest {
smtpAppender.setUsername("x");
smtpAppender.setPassword("x");
- smtpAppender.setLayout(buildPatternLayout(lc));
+ smtpAppender.setLayout(buildPatternLayout(loggerContext));
smtpAppender.start();
- Logger logger = lc.getLogger("test");
+ Logger logger = loggerContext.getLogger("test");
logger.addAppender(smtpAppender);
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
-
+ waitUntilEmailIsSent();
List<WiserMessage> wiserMsgList = wiser.getMessages();
assertNotNull(wiserMsgList);
@@ -252,14 +263,14 @@ public class SMTPAppender_SubethaSMTPTest {
smtpAppender.setUsername("xx");
smtpAppender.setPassword("xx");
- smtpAppender.setLayout(buildPatternLayout(lc));
+ smtpAppender.setLayout(buildPatternLayout(loggerContext));
smtpAppender.start();
- Logger logger = lc.getLogger("test");
+ Logger logger = loggerContext.getLogger("test");
logger.addAppender(smtpAppender);
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
- StatusPrinter.print(lc);
+ waitUntilEmailIsSent();
List<WiserMessage> wiserMsgList = wiser.getMessages();
assertNotNull(wiserMsgList);
@@ -277,14 +288,14 @@ public class SMTPAppender_SubethaSMTPTest {
smtpAppender.setUsername("XXX(a)gmail.com");
smtpAppender.setPassword("XXX");
- smtpAppender.setLayout(buildPatternLayout(lc));
+ smtpAppender.setLayout(buildPatternLayout(loggerContext));
smtpAppender.start();
- Logger logger = lc.getLogger("authenticatedGmailSTARTTLS");
+ Logger logger = loggerContext.getLogger("authenticatedGmailSTARTTLS");
logger.addAppender(smtpAppender);
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
- StatusPrinter.print(lc);
+ StatusPrinter.print(loggerContext);
}
@Test
@@ -298,25 +309,26 @@ public class SMTPAppender_SubethaSMTPTest {
smtpAppender.setUsername("XXX(a)gmail.com");
smtpAppender.setPassword("XXX");
- smtpAppender.setLayout(buildPatternLayout(lc));
+ smtpAppender.setLayout(buildPatternLayout(loggerContext));
smtpAppender.start();
- Logger logger = lc.getLogger("authenticatedGmail_SSL");
+ Logger logger = loggerContext.getLogger("authenticatedGmail_SSL");
logger.addAppender(smtpAppender);
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
- StatusPrinter.print(lc);
+ StatusPrinter.print(loggerContext);
}
@Test
public void testMultipleTo() throws Exception {
- smtpAppender.setLayout(buildPatternLayout(lc));
+ smtpAppender.setLayout(buildPatternLayout(loggerContext));
smtpAppender.addTo("Test <test(a)example.com>, other-test(a)example.com");
smtpAppender.start();
- Logger logger = lc.getLogger("test");
+ Logger logger = loggerContext.getLogger("test");
logger.addAppender(smtpAppender);
logger.debug("hello");
logger.error("en error", new Exception("an exception"));
+ waitUntilEmailIsSent();
List<WiserMessage> wiserMsgList = wiser.getMessages();
assertNotNull(wiserMsgList);
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
index d1df796..fd3247f 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeTest.java
@@ -160,30 +160,6 @@ public class ReconfigureOnChangeTest {
verify(expectedReconfigurations, mustBeErrorFree);
}
- // chose a test at random. These tests are rather long...
- // check for deadlocks
- @Test(timeout = 20000)
- public void randomTest() throws JoranException, IOException, InterruptedException {
- Random rand = new Random(System.currentTimeMillis());
- switch (rand.nextInt(5)) {
- case 0:
- scan1();
- break;
- case 1:
- scanWithFileInclusion();
- break;
- case 2:
- scanWithResourceInclusion();
- break;
- case 3:
- scan_lbclassic154();
- break;
- case 4:
- gscan1();
- break;
- }
- }
-
// Tests whether ConfigurationAction is installing ReconfigureOnChangeFilter
@Test
public void scan1() throws JoranException, IOException, InterruptedException {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/Context.java b/logback-core/src/main/java/ch/qos/logback/core/Context.java
index 463e4b7..cacfa2f 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/Context.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/Context.java
@@ -14,6 +14,8 @@
package ch.qos.logback.core;
import java.util.Map;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
import ch.qos.logback.core.spi.PropertyContainer;
import ch.qos.logback.core.status.StatusManager;
@@ -103,4 +105,13 @@ public interface Context extends PropertyContainer {
*/
public Object getConfigurationLock();
+
+ /**
+ * Every context has an ExecutorService which be invoked to execute certain
+ * tasks in a separate thread.
+ *
+ * @return the executor for this context.
+ * @since 1.0.0
+ */
+ public ExecutorService getExecutorService();
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java b/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java
index 4588344..0f61df4 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java
@@ -15,8 +15,10 @@ package ch.qos.logback.core;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.*;
import ch.qos.logback.core.status.StatusManager;
+
import static ch.qos.logback.core.CoreConstants.CONTEXT_NAME_KEY;
public class ContextBase implements Context {
@@ -33,6 +35,11 @@ public class ContextBase implements Context {
Object configurationLock = new Object();
+ // 0 idle threads, 2 maximum threads, no idle waiting
+ ExecutorService executorService = new ThreadPoolExecutor(0, 2,
+ 0L, TimeUnit.MILLISECONDS,
+ new LinkedBlockingQueue<Runnable>());
+
public StatusManager getStatusManager() {
return sm;
}
@@ -41,12 +48,11 @@ public class ContextBase implements Context {
* Set the {@link StatusManager} for this context. Note that by default this
* context is initialized with a {@link BasicStatusManager}. A null value for
* the 'statusManager' argument is not allowed.
- *
+ * <p/>
* <p> A malicious attacker can set the status manager to a dummy instance,
* disabling internal error reporting.
*
- * @param statusManager
- * the new status manager
+ * @param statusManager the new status manager
*/
public void setStatusManager(StatusManager statusManager) {
// this method was added in response to http://jira.qos.ch/browse/LBCORE-35
@@ -72,8 +78,8 @@ public class ContextBase implements Context {
* @return
*/
public String getProperty(String key) {
- if(CONTEXT_NAME_KEY.equals(key))
- return getName();
+ if (CONTEXT_NAME_KEY.equals(key))
+ return getName();
return (String) this.propertyMap.get(key);
}
@@ -103,15 +109,14 @@ public class ContextBase implements Context {
* current name is the default context name, namely "default", or if the
* current name and the old name are the same.
*
- * @throws IllegalStateException
- * if the context already has a name, other than "default".
+ * @throws IllegalStateException if the context already has a name, other than "default".
*/
public void setName(String name) throws IllegalStateException {
if (name != null && name.equals(this.name)) {
return; // idempotent naming
}
if (this.name == null
- || CoreConstants.DEFAULT_CONTEXT_NAME.equals(this.name)) {
+ || CoreConstants.DEFAULT_CONTEXT_NAME.equals(this.name)) {
this.name = name;
} else {
throw new IllegalStateException("Context has been already given a name");
@@ -125,4 +130,8 @@ public class ContextBase implements Context {
public Object getConfigurationLock() {
return configurationLock;
}
+
+ public ExecutorService getExecutorService() {
+ return executorService;
+ }
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java b/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java
index 1eec119..6e92600 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java
@@ -48,6 +48,15 @@ public class CyclicBuffer<E> {
init(maxSize);
}
+ public CyclicBuffer(CyclicBuffer<E> other) {
+ this.maxSize = other.maxSize;
+ ea = (E[]) new Object[maxSize];
+ System.arraycopy(other.ea, 0, this.ea, 0, maxSize);
+ this.last = other.last;
+ this.first = other.first;
+ this.numElems = other.numElems;
+ }
+
@SuppressWarnings("unchecked")
private void init(int maxSize) {
this.maxSize = maxSize;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
index e6790a2..494afdb 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
@@ -177,12 +177,16 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
String key = discriminator.getDiscriminatingValue(eventObject);
long now = System.currentTimeMillis();
- CyclicBuffer<E> cb = cbTracker.getOrCreate(key, now);
+ final CyclicBuffer<E> cb = cbTracker.getOrCreate(key, now);
subAppend(cb, eventObject);
+ cb.asList();
+
try {
if (eventEvaluator.evaluate(eventObject)) {
- sendBuffer(cb, eventObject);
+ // perform actual sending asynchronously
+ SenderRunnable senderRunnable = new SenderRunnable(new CyclicBuffer<E>(cb), eventObject);
+ context.getExecutorService().execute(senderRunnable);
}
} catch (EvaluationException ex) {
errorCount++;
@@ -583,4 +587,17 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
this.layout = layout;
}
+ class SenderRunnable implements Runnable {
+
+ final CyclicBuffer<E> cyclicBuffer;
+ final E e;
+
+ SenderRunnable(CyclicBuffer<E> cyclicBuffer, E e) {
+ this.cyclicBuffer = cyclicBuffer;
+ this.e = e;
+ }
+ public void run() {
+ sendBuffer(cyclicBuffer, e);
+ }
+ }
}
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index 4334f4e..0d997d7 100644
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -1696,9 +1696,10 @@ public interface TriggeringPolicy<E> extends LifeCycle {
href="../xref/ch/qos/logback/classic/net/SMTPAppender.html"><code>SMTPAppender</code></a>
accumulates logging events in one or more fixed-size buffers and
sends the contents of the appropriate buffer in an email after a
- user-specified event occurs. By default, the email transmission is
- triggered by a logging event of level ERROR or higher. Moreover, by
- default, a single buffer is used for all events.
+ user-specified event occurs. SMTP email transmission (sending) is
+ performed asynchronously. By default, the email transmission is
+ triggered by a logging event of level ERROR. Moreover, by default,
+ a single buffer is used for all events.
</p>
<p>The various properties for <code>SMTPAppender</code> are
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index fa96c57..452d37f 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -54,6 +54,8 @@
Alexandre Garnier.
</p>
+ <p><code>SMTPAppender</code> now sends emails asynchronously.</p>
+
<p>Investigation of <a
href="http://jira.qos.ch/browse/LBCORE-224">LBCORE-224</a>
reported by Cesar Alvarez Nunez points to bug in the JVM rather
diff --git a/pom.xml b/pom.xml
index 592a633..95d9c69 100755
--- a/pom.xml
+++ b/pom.xml
@@ -31,7 +31,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- slf4j.version property is used below, in
logback-classic/pom.xml and in setClasspath.cmd -->
- <slf4j.version>1.6.2</slf4j.version>
+ <slf4j.version>1.6.3</slf4j.version>
<junit.version>4.8.2</junit.version>
<janino.version>2.5.10</janino.version>
<scala.version>2.9.1</scala.version>
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/access/tomcat/LogbackValve.java | 10 +++
.../classic/turbo/ReconfigureOnChangeFilter.java | 4 +-
.../classic/net/SMTPAppender_GreenTest.java | 19 ++++++-
.../classic/net/SMTPAppender_SubethaSMTPTest.java | 60 ++++++++++++--------
.../classic/turbo/ReconfigureOnChangeTest.java | 24 --------
.../src/main/java/ch/qos/logback/core/Context.java | 11 ++++
.../main/java/ch/qos/logback/core/ContextBase.java | 25 ++++++---
.../ch/qos/logback/core/helpers/CyclicBuffer.java | 9 +++
.../ch/qos/logback/core/net/SMTPAppenderBase.java | 21 ++++++-
logback-site/src/site/pages/manual/appenders.html | 7 +-
logback-site/src/site/pages/news.html | 2 +
pom.xml | 2 +-
12 files changed, 128 insertions(+), 66 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0
When running a 'mvn package' from the top level of the logback project,
I'm getting intermittent failure on durationOfDisabledLog_NoParameters
in LoggerPerfTest. My computer is quite fast (i7 2600K, 8GB, linux
3.0.4, jdk 1.6u27)
When I run the test by itself from my IDE, it passes with the following
output:
durationOfDisabledLog_NoParameters=2.0
Host runs at 96906.22045874437 BIPS
currentBIPS=84956.35367330034 BIPS
The test also succeeds when I run mvn with -Dtest=LoggerPerfTest
-DfailIfNoTests=false.
Contents of the surefire report from one such failure:
-------------------------------------------------------------------------------
Test set: ch.qos.logback.classic.LoggerPerfTest
-------------------------------------------------------------------------------
Tests run: 6, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.589
sec <<< FAILURE!
durationOfDisabledLogsWith_1_NOPFilter(ch.qos.logback.classic.LoggerPerfTest)
Time elapsed: 0.026 sec
durationOfIsDebugEnabled(ch.qos.logback.classic.LoggerPerfTest) Time
elapsed: 0.1 sec
durationOfDisabledLog_NoParameters(ch.qos.logback.classic.LoggerPerfTest)
Time elapsed: 0.19 sec <<< FAILURE!
junit.framework.AssertionFailedError: current duration 6.0 exceeded
expected 1.8218115000000001 (adjusted reference), 18 (raw reference)
at org.slf4j.helpers.BogoPerf.assertDuration(BogoPerf.java:121)
at
ch.qos.logback.classic.LoggerPerfTest.durationOfDisabledLog_NoParameters(LoggerPerfTest.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:120)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:103)
at org.apache.maven.surefire.Surefire.run(Surefire.java:169)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
durationOfDisabledLog_1_Parameter(ch.qos.logback.classic.LoggerPerfTest)
Time elapsed: 0.017 sec
durationOfEnabledLog(ch.qos.logback.classic.LoggerPerfTest) Time
elapsed: 0 sec
testThreadedLogging(ch.qos.logback.classic.LoggerPerfTest) Time
elapsed: 1.254 sec
1
0

[JIRA] Created: (LBCLASSIC-171) Exception data sometimes does not get logged when using warn(String, Throwable)
by Marshall Pierce (JIRA) 25 Oct '11
by Marshall Pierce (JIRA) 25 Oct '11
25 Oct '11
Exception data sometimes does not get logged when using warn(String, Throwable)
-------------------------------------------------------------------------------
Key: LBCLASSIC-171
URL: http://jira.qos.ch/browse/LBCLASSIC-171
Project: logback-classic
Issue Type: Bug
Affects Versions: 0.917
Environment: Linux, sun jdk 1.6.0_07
Reporter: Marshall Pierce
Assignee: Logback dev list
Source:
try {
doStuff();
} catch (PhaseException e) {
this.logger.warn("Phase failed:", e);
this.logger.debug("Another log message");
...
Log contents:
phase.StandardPhase - Phase failed:
phase.StandardPhase - Another log message
The strange thing is that this doesn't happen all the time or even most of the time. Almost always, the exception data does get logged.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
2
3