[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.18-85-ge06bc4a
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Wed Mar 17 17:45:36 CET 2010
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 e06bc4a748fea6af5e4878a5e411ea18d5a5fcdc (commit)
via 3ad9ae244a7db6233256d89f9513807f562cbdb2 (commit)
from 3faa7d8bc517251201915d2add3e2f86cc25a649 (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=e06bc4a748fea6af5e4878a5e411ea18d5a5fcdc
http://github.com/ceki/logback/commit/e06bc4a748fea6af5e4878a5e411ea18d5a5fcdc
commit e06bc4a748fea6af5e4878a5e411ea18d5a5fcdc
Author: Ceki Gulcu <ceki at qos.ch>
Date: Wed Mar 17 17:44:30 2010 +0100
- SiftingAppender now exposes its AppenderTracker. Moreover, the
stopAndRemoveNow(String key) method was added to AppenderTracker,
allowing immediate removal of a nested appender.
- minor editing of the manual
diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java
index de3cea3..6e75c85 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java
@@ -27,6 +27,5 @@ public interface AppenderTracker<E> {
void stopStaleAppenders(long timestamp);
List<String> keyList();
List<Appender<E>> valueList();
-
-
+ void stopAndRemoveNow(String key);
}
\ No newline at end of file
diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java
index e6ef0f7..4697b55 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java
@@ -74,6 +74,28 @@ public class AppenderTrackerImpl<E> implements AppenderTracker<E> {
}
}
+ /**
+ * @since 0.9.19
+ * @param key
+ */
+ public synchronized void stopAndRemoveNow(String key) {
+ Entry e = head;
+ Entry found = null;
+ while (e != tail) {
+ if(key.equals(e.key)) {
+ found = e;
+ break;
+ }
+ e = e.next;
+ }
+ if(found != null) {
+ rearrangePreexistingLinks(e);
+ map.remove(key);
+ Appender appender = e.value;
+ appender.stop();
+ }
+ }
+
public List<String> keyList() {
List<String> result = new LinkedList<String>();
Entry e = head;
diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java b/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java
index 85af51a..e82a83e 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/sift/AppenderTrackerTest.java
@@ -31,6 +31,7 @@ public class AppenderTrackerTest {
Context context = new ContextBase();
AppenderTracker<Object> appenderTracker = new AppenderTrackerImpl<Object>();
ListAppender<Object> la = new ListAppender<Object>();
+ String key = "a";
@Before
public void setUp() {
@@ -49,26 +50,31 @@ public class AppenderTrackerTest {
@Test
public void empty1() {
long now = 3000;
- assertNull(appenderTracker.get("a", now++));
+ assertNull(appenderTracker.get(key, now++));
now += AppenderTrackerImpl.THRESHOLD+1000;
appenderTracker.stopStaleAppenders(now);
- assertNull(appenderTracker.get("a", now++));
+ assertNull(appenderTracker.get(key, now++));
}
@Test
public void smoke() {
assertTrue(la.isStarted());
long now = 3000;
- appenderTracker.put("a", la, now);
- assertEquals(la, appenderTracker.get("a", now++));
+ appenderTracker.put(key, la, now);
+ assertEquals(la, appenderTracker.get(key, now++));
now += AppenderTrackerImpl.THRESHOLD+1000;
appenderTracker.stopStaleAppenders(now);
assertFalse(la.isStarted());
- assertNull(appenderTracker.get("a", now++));
+ assertNull(appenderTracker.get(key, now++));
}
-
+
@Test
- public void scenarioBased() {
-
- }
+ public void removeNow() {
+ long now = 3000;
+ appenderTracker.put(key, la, now);
+ appenderTracker.stopAndRemoveNow(key);
+ assertFalse(la.isStarted());
+ appenderTracker.get(key, now++);
+ assertNull(appenderTracker.get(key, now++));
+ }
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/sift/PackageTest.java
index 28af860..2446b02 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/sift/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/sift/PackageTest.java
@@ -18,6 +18,6 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
- at SuiteClasses({ScenarioBasedAppenderTrackerTest.class})
+ at SuiteClasses({AppenderTrackerTest.class, ScenarioBasedAppenderTrackerTest.class})
public class PackageTest {
}
\ No newline at end of file
diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/ScenarioBasedAppenderTrackerTest.java b/logback-core/src/test/java/ch/qos/logback/core/sift/ScenarioBasedAppenderTrackerTest.java
index 6f21a1e..8a2e038 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/sift/ScenarioBasedAppenderTrackerTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/sift/ScenarioBasedAppenderTrackerTest.java
@@ -22,34 +22,52 @@ public class ScenarioBasedAppenderTrackerTest {
Simulator simulator;
+ int INVERSE_OF_NO_REMOVE = Integer.MAX_VALUE;
+
+
void verify() {
- AppenderTracker at = simulator.appenderTracker;
+ AppenderTracker at = simulator.realAppenderTracker;
AppenderTracker t_at = simulator.t_appenderTracker;
- //List<String> resultKeys = at.keyList();
- //List<String> witnessKeys = t_at.keyList();
assertEquals(t_at.keyList(), at.keyList());
}
-
+
@Test
public void shortTest() {
- simulator = new Simulator(20, AppenderTracker.THRESHOLD / 2);
+ simulator = new Simulator(20, AppenderTracker.THRESHOLD / 2, INVERSE_OF_NO_REMOVE);
simulator.buildScenario(200);
simulator.simulate();
verify();
}
+
+ @Test
+ public void shortTestWithRemovals() {
+ simulator = new Simulator(10, AppenderTracker.THRESHOLD / 10, 2);
+ simulator.buildScenario(200);
+ simulator.simulate();
+ verify();
+ }
+
@Test
public void mediumTest() {
- simulator = new Simulator(100, AppenderTracker.THRESHOLD / 2);
+ simulator = new Simulator(100, AppenderTracker.THRESHOLD / 2, INVERSE_OF_NO_REMOVE);
simulator.buildScenario(20000);
simulator.simulate();
verify();
}
@Test
+ public void mediumTestWithRemovals() {
+ simulator = new Simulator(10, AppenderTracker.THRESHOLD / 100, 2);
+ simulator.buildScenario(20000);
+ simulator.simulate();
+ verify();
+ }
+
+ @Test
@Ignore
- public void longetTest() {
- simulator = new Simulator(100, AppenderTracker.THRESHOLD / 200);
+ public void longTest() {
+ simulator = new Simulator(100, AppenderTracker.THRESHOLD / 200, 10);
simulator.buildScenario(2000000);
simulator.simulate();
verify();
diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/Simulator.java b/logback-core/src/test/java/ch/qos/logback/core/sift/Simulator.java
index 16cf0f0..db91d02 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/sift/Simulator.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/sift/Simulator.java
@@ -23,16 +23,17 @@ import ch.qos.logback.core.Appender;
import ch.qos.logback.core.appender.NOPAppender;
import ch.qos.logback.core.sift.tracker.AppenderTrackerTImpl;
import ch.qos.logback.core.sift.tracker.SimulationEvent;
+import ch.qos.logback.core.sift.tracker.SimulationEvent.SimEventType;
/**
- * Simulate use of AppenderTracker by HoardAppender.
+ * Simulate use of AppenderTracker by SiftingAppender.
*
* @author ceki
- *
+ *
*/
public class Simulator {
- AppenderTrackerImpl<Object> appenderTracker = new AppenderTrackerImpl<Object>();
+ AppenderTrackerImpl<Object> realAppenderTracker = new AppenderTrackerImpl<Object>();
AppenderTrackerTImpl t_appenderTracker = new AppenderTrackerTImpl();
List<String> keySpace = new ArrayList<String>();
@@ -42,10 +43,11 @@ public class Simulator {
Random random = new Random(11234);
final int maxTimestampInc;
- long timestamp = 30000;
+ final int inverseOfRemoveProbability;
- Simulator(int keySpaceLen, int maxTimestampInc) {
+ Simulator(int keySpaceLen, int maxTimestampInc, int inverseOfRemoveProbability) {
this.maxTimestampInc = maxTimestampInc;
+ this.inverseOfRemoveProbability = inverseOfRemoveProbability;
Map<String, String> checkMap = new HashMap<String, String>();
for (int i = 0; i < keySpaceLen; i++) {
String k = getRandomKeyStr();
@@ -66,31 +68,65 @@ public class Simulator {
}
void buildScenario(int simLen) {
+ long timestamp = 30000;
int keySpaceLen = keySpace.size();
for (int i = 0; i < simLen; i++) {
int index = random.nextInt(keySpaceLen);
timestamp += random.nextInt(maxTimestampInc);
String key = keySpace.get(index);
- scenario.add(new SimulationEvent(key, timestamp));
+ SimEventType eventType = SimEventType.PUT;
+
+ int removeNow = random.nextInt(inverseOfRemoveProbability);
+ if (removeNow == 0) {
+ eventType = SimEventType.REMOVE_NOW;
+ }
+ scenario.add(new SimulationEvent(eventType, key, timestamp));
+ }
+ }
+
+ void dump() {
+ for (SimulationEvent simeEvent : scenario) {
+ System.out.println(simeEvent);
}
}
public void simulate() {
for (SimulationEvent simeEvent : scenario) {
- play(simeEvent, appenderTracker);
+ play(simeEvent, realAppenderTracker);
play(simeEvent, t_appenderTracker);
}
}
void play(SimulationEvent simulationEvent,
AppenderTracker<Object> appenderTracker) {
- String mdcValue = simulationEvent.key;
+ String key = simulationEvent.key;
long timestamp = simulationEvent.timestamp;
- Appender<Object> appender = appenderTracker.get(mdcValue, timestamp);
+
+ switch (simulationEvent.simEventType) {
+ case PUT:
+ doPut(appenderTracker, key, timestamp);
+ break;
+ case REMOVE_NOW:
+ doRemoveNow(appenderTracker, key);
+ break;
+ }
+
+ }
+
+ void doPut(AppenderTracker<Object> appenderTracker, String key, long timestamp) {
+ Appender<Object> appender = appenderTracker.get(key, timestamp);
if (appender == null) {
appender = new NOPAppender<Object>();
- appenderTracker.put(mdcValue, appender, timestamp);
+ appenderTracker.put(key, appender, timestamp);
}
appenderTracker.stopStaleAppenders(timestamp);
}
+
+ int i = 0;
+
+ void doRemoveNow(AppenderTracker<Object> appenderTracker, String key) {
+ // System.out.println("doRemoveNow "+(i++));
+ appenderTracker.stopAndRemoveNow(key);
+ }
+
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java b/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java
index 1a33637..3b8e546 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java
@@ -70,6 +70,20 @@ public class AppenderTrackerTImpl implements AppenderTracker<Object> {
}
}
+ synchronized public void stopAndRemoveNow(String key) {
+ TEntry found = null;
+ for (TEntry te : entryList) {
+ if (key.equals(te.key)) {
+ found = te;
+ break;
+ }
+ }
+ if (found != null) {
+ entryList.remove(found);
+ }
+
+ }
+
final private boolean isEntryStale(TEntry entry, long now) {
return ((entry.timestamp + THRESHOLD) < now);
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/SimulationEvent.java b/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/SimulationEvent.java
index b04e52f..09ae7c1 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/SimulationEvent.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/SimulationEvent.java
@@ -16,15 +16,21 @@ package ch.qos.logback.core.sift.tracker;
public class SimulationEvent {
- public String key;
- public long timestamp;
-
- public SimulationEvent(String key, long timestamp) {
+ public enum SimEventType {
+ PUT, REMOVE_NOW;
+ }
+
+ final public String key;
+ final public long timestamp;
+ final public SimEventType simEventType;
+
+ public SimulationEvent(SimEventType simEventType, String key, long timestamp) {
+ this.simEventType = simEventType;
this.key = key;
this.timestamp = timestamp;
}
public String toString() {
- return "Event: k=" + key +", timestamp=" + timestamp;
+ return "Type: "+simEventType+", Event: k=" + key +", timestamp=" + timestamp;
}
}
diff --git a/logback-site/src/site/pages/manual/introduction.html b/logback-site/src/site/pages/manual/introduction.html
index 45748ec..ed1b347 100644
--- a/logback-site/src/site/pages/manual/introduction.html
+++ b/logback-site/src/site/pages/manual/introduction.html
@@ -23,7 +23,7 @@
</div>
<div id="content">
- <h1>Introduction</h1>
+ <h1>Chapter 1: Introduction</h1>
<div class="quote">
<p><em> The morale effects are startling. Enthusiasm jumps when
diff --git a/logback-site/src/site/pages/manual/jmxConfig.html b/logback-site/src/site/pages/manual/jmxConfig.html
index 91c4c0e..e56f951 100644
--- a/logback-site/src/site/pages/manual/jmxConfig.html
+++ b/logback-site/src/site/pages/manual/jmxConfig.html
@@ -25,7 +25,7 @@
</div>
<div id="content">
- <h2>Chapter 10: JMX Configurator</h2>
+ <h1>Chapter 10: JMX Configurator</h1>
<p>As its name indicates, <code>JMXConfigurator</code> allows
configuration of logback via JMX. In a nutshell, it lets you
diff --git a/logback-site/src/site/pages/manual/loggingSeparation.html b/logback-site/src/site/pages/manual/loggingSeparation.html
index ecea848..d366182 100644
--- a/logback-site/src/site/pages/manual/loggingSeparation.html
+++ b/logback-site/src/site/pages/manual/loggingSeparation.html
@@ -23,7 +23,7 @@
</div>
<div id="content">
- <h2>Chapter 9: Logging separation</h2>
+ <h1>Chapter 9: Logging separation</h1>
<div class="quote">
<p><em>It is not knowledge, but the act of learning, not
diff --git a/logback-site/src/site/pages/manual/migrationFromLog4j.html b/logback-site/src/site/pages/manual/migrationFromLog4j.html
index dd392cf..d34f043 100644
--- a/logback-site/src/site/pages/manual/migrationFromLog4j.html
+++ b/logback-site/src/site/pages/manual/migrationFromLog4j.html
@@ -23,7 +23,7 @@
</div>
<div id="content">
- <h2>Chapter 12: Migration from log4j</h2>
+ <h1>Chapter 12: Migration from log4j</h1>
<div class="quote">
<p><em>The more things change, the more they remain the
diff --git a/logback-site/src/site/pages/manual/onJoran.html b/logback-site/src/site/pages/manual/onJoran.html
index 9c6f259..84d3395 100644
--- a/logback-site/src/site/pages/manual/onJoran.html
+++ b/logback-site/src/site/pages/manual/onJoran.html
@@ -23,7 +23,7 @@
</div>
<div id="content">
- <h2>Chapter 11: Joran</h2>
+ <h1>Chapter 11: Joran</h1>
<div class="quote">
<p><em>The answer, my friend, is blowin' in the wind, The answer
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 1deacc2..b6b13a3 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -69,9 +69,9 @@
</p>
<p>Fixed <a
- href="http://jira.qos.ch/browse/LBCLASSIC-193">LBCLASSIC-193</a>. <code>SyslogAppender</code>
- will no longer shutdown when messages over 256Kb cause an
- <code>IOException</code>.
+ href="http://jira.qos.ch/browse/LBCLASSIC-193">LBCLASSIC-193</a>.
+ <code>SyslogAppender</code> will no longer shutdown when messages
+ over 256Kb cause an <code>IOException</code>.
</p>
<p>Added <a
@@ -97,10 +97,17 @@
surrounding child elements is ignored.
</p>
+ <p><code>SiftingAppender</code> now exposes its
+ <code>AppenderTracker</code>. Moreover, the
+ <code>stopAndRemoveNow(String key)</code> method was added to
+ <code>AppenderTracker</code>, allowing immediate removal of a
+ nested appender.
+ </p>
<p>Fixed <a
- href="http://jira.qos.ch/browse/LBCORE-130">LBCORE-130</a>. <code>FileNamePattern</code>
- no longer treats parenthesis as special.
+ href="http://jira.qos.ch/browse/LBCORE-130">LBCORE-130</a>.
+ <code>FileNamePattern</code> no longer treats parenthesis as
+ special.
</p>
<p>The <span class="option">CharsetEncoder</span> property in
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=3ad9ae244a7db6233256d89f9513807f562cbdb2
http://github.com/ceki/logback/commit/3ad9ae244a7db6233256d89f9513807f562cbdb2
commit 3ad9ae244a7db6233256d89f9513807f562cbdb2
Author: Ceki Gulcu <ceki at qos.ch>
Date: Wed Mar 17 14:40:26 2010 +0100
- added getAppenderTracer method in SiftingAppender
- the contextName attribute in jmxConfigurator is redundant since the
context name can be set with the <contextName> element. Modified
documentation accordingly. This change was triggered by comments made
by Matthias Kretschmar.
diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java
index 82c15e0..dbfe217 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/sift/SiftingAppenderBase.java
@@ -81,7 +81,8 @@ public abstract class SiftingAppenderBase<E> extends
appenderTracker.put(discriminatingValue, appender, timestamp);
}
} catch (JoranException e) {
- addError("Failed to build appender for [" + discriminatingValue + "]", e);
+ addError("Failed to build appender for [" + discriminatingValue + "]",
+ e);
return;
}
}
@@ -97,9 +98,20 @@ public abstract class SiftingAppenderBase<E> extends
this.discriminator = discriminator;
}
-
+ // sometime one needs to close a nested appender immediately
+ // for example when executing a command which has its own nested appender
+ // and the command also cleans up after itself. However, an open file appender
+ // will prevent the folder from being deleted
+ // see http://www.qos.ch/pipermail/logback-user/2010-March/001487.html
+ /**
+ * @since 0.9.19
+ */
+ public AppenderTracker getAppenderTracer() {
+ return appenderTracker;
+ }
+
public String getDiscriminatorKey() {
- if(discriminator != null) {
+ if (discriminator != null) {
return discriminator.getKey();
} else {
return null;
diff --git a/logback-site/src/site/pages/manual/jmxConfig.html b/logback-site/src/site/pages/manual/jmxConfig.html
index 5481188..91c4c0e 100644
--- a/logback-site/src/site/pages/manual/jmxConfig.html
+++ b/logback-site/src/site/pages/manual/jmxConfig.html
@@ -155,11 +155,10 @@ public class MyContextListener implements ServletContextListener {
web-applications will collide.
</p>
- <p>To avoid such undesirable collisions, you can instruct each
- <code>JMXConfigurator</code> instance to have a different name by
- setting the "contextName" attribute of the
- <code><jmxConfigurator></code> element in the logback
- configuration file.
+ <p>To avoid such undesirable collisions, you simply <a
+ href="configuration.html#contextName">set the name of your
+ application's logging context</a> and <code>JMXConfigurator</code>
+ will automatically use the name you have set.
</p>
<p>For example, if you deploy two web-applications named "Koala"
@@ -167,11 +166,19 @@ public class MyContextListener implements ServletContextListener {
configuration
</p>
- <p class="source"><jmxConfigurator <b>contextName="Koala"</b> /></p>
+ <pre class="prettyprint source"><configuration>
+ <b><contextName>Koala</contextName></b>
+ <jmxConfigurator/>
+ ...
+<configuration></pre>
<p>and in Wombat logback configuration file, you would write:</p>
- <p class="source"><jmxConfigurator <b>contextName="Womcat"</b> /></p>
+ <pre class="prettyprint source"><configuration>
+ <b><contextName>Wombat</contextName></b>x
+ <jmxConfigurator/>
+ ...
+<configuration></pre>
<p>In jconsole's MBeans panel, you would two distinct
<code>JMXConfigurator</code> instances:</p>
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/core/sift/AppenderTracker.java | 3 +-
.../qos/logback/core/sift/AppenderTrackerImpl.java | 22 ++++++++
.../qos/logback/core/sift/SiftingAppenderBase.java | 18 +++++-
.../qos/logback/core/sift/AppenderTrackerTest.java | 24 +++++---
.../java/ch/qos/logback/core/sift/PackageTest.java | 2 +-
.../sift/ScenarioBasedAppenderTrackerTest.java | 34 +++++++++---
.../java/ch/qos/logback/core/sift/Simulator.java | 56 ++++++++++++++++----
.../core/sift/tracker/AppenderTrackerTImpl.java | 14 +++++
.../logback/core/sift/tracker/SimulationEvent.java | 16 ++++--
.../src/site/pages/manual/introduction.html | 2 +-
logback-site/src/site/pages/manual/jmxConfig.html | 23 +++++---
.../src/site/pages/manual/loggingSeparation.html | 2 +-
.../src/site/pages/manual/migrationFromLog4j.html | 2 +-
logback-site/src/site/pages/manual/onJoran.html | 2 +-
logback-site/src/site/pages/news.html | 17 ++++--
15 files changed, 182 insertions(+), 55 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list