[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.20-10-g62ef363
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Fri Apr 23 17:32:52 CEST 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 62ef3635ed5d87c13286e710e0b1f3c6f327a1a6 (commit)
from 11ae2ad01ed9cc2f084b9b2c28a2c24c5faaf77b (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=62ef3635ed5d87c13286e710e0b1f3c6f327a1a6
http://github.com/ceki/logback/commit/62ef3635ed5d87c13286e710e0b1f3c6f327a1a6
commit 62ef3635ed5d87c13286e710e0b1f3c6f327a1a6
Author: Ceki Gulcu <ceki at qos.ch>
Date: Fri Apr 23 17:28:00 2010 +0200
- upgrade to SLF4J 1.6.0-RC0
Logger class changed to comply with changes in LoggingLocationAware interface
LoggingEvent changeed to comply with changes in MessgageFormatter
LoggingEventVO changeed to comply with changes in MessgageFormatter
- test cases related to http://jira.qos.ch/browse/LBCLASSIC-203
diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml
index 40954d4..032c8c9 100644
--- a/logback-classic/pom.xml
+++ b/logback-classic/pom.xml
@@ -264,7 +264,7 @@
<exclude>**/TestConstants.java</exclude>
<exclude>**/test_osgi/BundleTest.java</exclude>
org.slf4j.test_osgi
- <exclude>**/SerializationPerfsTest.java</exclude>
+ <exclude>**/SerializationPerfTest.java</exclude>
</excludes>
</configuration>
</plugin>
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java b/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
index 0d2957f..67c7b43 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
@@ -80,12 +80,18 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
* synchronized on 'this' (Logger) protecting against simultaneous
* re-configuration of this logger (a very unlikely scenario).
*
- * <p> It is further assumed that the AppenderAttachableImpl is responsible
- * for its internal synchronization and thread safety. Thus, we can get away
- * with *not* synchronizing on the 'aai' (check null/ read) because <p> 1) the
- * 'aai' variable is immutable once set to non-null <p> 2) 'aai' is getAndSet
- * only within addAppender which is synchronized <p> 3) all the other methods
- * check whether 'aai' is null <p> 4) AppenderAttachableImpl is thread safe
+ * <p>
+ * It is further assumed that the AppenderAttachableImpl is responsible for
+ * its internal synchronization and thread safety. Thus, we can get away with
+ * *not* synchronizing on the 'aai' (check null/ read) because
+ * <p>
+ * 1) the 'aai' variable is immutable once set to non-null
+ * <p>
+ * 2) 'aai' is getAndSet only within addAppender which is synchronized
+ * <p>
+ * 3) all the other methods check whether 'aai' is null
+ * <p>
+ * 4) AppenderAttachableImpl is thread safe
*/
private transient AppenderAttachableImpl<ILoggingEvent> aai;
/**
@@ -158,17 +164,18 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
// nothing to do;
return;
}
- if(newLevel == null && isRootLogger()) {
- throw new IllegalArgumentException("The level of the root logger cannot be set to null");
+ if (newLevel == null && isRootLogger()) {
+ throw new IllegalArgumentException(
+ "The level of the root logger cannot be set to null");
}
-
+
level = newLevel;
if (newLevel == null) {
effectiveLevelInt = parent.effectiveLevelInt;
} else {
effectiveLevelInt = newLevel.levelInt;
}
-
+
if (childrenList != null) {
int len = childrenList.size();
for (int i = 0; i < len; i++) {
@@ -203,8 +210,9 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
}
/**
- * Remove all previously added appenders from this logger instance. <p/> This
- * is useful when re-reading configuration information.
+ * Remove all previously added appenders from this logger instance.
+ * <p/>
+ * This is useful when re-reading configuration information.
*/
public void detachAndStopAllAppenders() {
if (aai != null) {
@@ -254,7 +262,7 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
* Invoke all the appenders of this logger.
*
* @param event
- * The event to log
+ * The event to log
*/
public void callAppenders(ILoggingEvent event) {
int writes = 0;
@@ -291,7 +299,7 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
static int getSeparatorIndexOf(String name) {
return getSeparatorIndexOf(name, 0);
}
-
+
/**
* Get the position of the separator character, if any, starting at position
* 'fromIndex'.
@@ -300,35 +308,35 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
* @param fromIndex
* @return
*/
- static int getSeparatorIndexOf(String name, int fromIndex) {
+ static int getSeparatorIndexOf(String name, int fromIndex) {
int i = name.indexOf(CoreConstants.DOT, fromIndex);
- if(i != -1) {
+ if (i != -1) {
return i;
} else {
return name.indexOf(CoreConstants.DOLLAR, fromIndex);
}
}
-
+
/**
* Create a child of this logger by suffix, that is, the part of the name
* extending this logger. For example, if this logger is named "x.y" and the
* lastPart is "z", then the created child logger will be named "x.y.z".
*
- * <p> IMPORTANT: Calls to this method must be within a synchronized block on
- * this logger.
+ * <p>
+ * IMPORTANT: Calls to this method must be within a synchronized block on this
+ * logger.
*
* @param lastPart
- * the suffix (i.e. last part) of the child logger name. This
- * parameter may not include dots, i.e. the logger separator
- * character.
+ * the suffix (i.e. last part) of the child logger name. This
+ * parameter may not include dots, i.e. the logger separator
+ * character.
* @return
*/
Logger createChildByLastNamePart(final String lastPart) {
int i_index = getSeparatorIndexOf(lastPart);
if (i_index != -1) {
throw new IllegalArgumentException("Child name [" + lastPart
- + " passed as parameter, may not include ["
- + CoreConstants.DOT + "]");
+ + " passed as parameter, may not include [" + CoreConstants.DOT + "]");
}
if (childrenList == null) {
@@ -338,8 +346,7 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
if (this.isRootLogger()) {
childLogger = new Logger(lastPart, this, this.loggerContext);
} else {
- childLogger = new Logger(
- name + CoreConstants.DOT + lastPart, this,
+ childLogger = new Logger(name + CoreConstants.DOT + lastPart, this,
this.loggerContext);
}
childrenList.add(childLogger);
@@ -349,13 +356,13 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
private void localLevelReset() {
effectiveLevelInt = Level.DEBUG_INT;
- if(isRootLogger()) {
+ if (isRootLogger()) {
level = Level.DEBUG;
} else {
level = null;
}
}
-
+
void recursiveReset() {
detachAndStopAllAppenders();
localLevelReset();
@@ -375,8 +382,7 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
static private final int DEFAULT_CHILD_ARRAY_SIZE = 5;
Logger createChildByName(final String childName) {
- int i_index = getSeparatorIndexOf(childName, this.name
- .length() + 1);
+ int i_index = getSeparatorIndexOf(childName, this.name.length() + 1);
if (i_index != -1) {
throw new IllegalArgumentException("For logger [" + this.name
+ "] child name [" + childName
@@ -814,7 +820,7 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
}
public void log(Marker marker, String fqcn, int levelInt, String message,
- Throwable t) {
+ Object[] argArray, Throwable t) {
Level level = null;
switch (levelInt) {
case LocationAwareLogger.TRACE_INT:
@@ -835,7 +841,7 @@ public final class Logger implements org.slf4j.Logger, LocationAwareLogger,
default:
throw new IllegalArgumentException(levelInt + " not a valid level value");
}
- filterAndLog_0_Or3Plus(fqcn, marker, level, message, null, t);
+ filterAndLog_0_Or3Plus(fqcn, marker, level, message, argArray, t);
}
/**
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
index 867c9d2..774c5fd 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
@@ -18,6 +18,7 @@ import java.util.Map;
import org.slf4j.MDC;
import org.slf4j.Marker;
+import org.slf4j.helpers.FormattingTuple;
import org.slf4j.helpers.MessageFormatter;
import ch.qos.logback.classic.Level;
@@ -30,11 +31,13 @@ import ch.qos.logback.classic.util.LogbackMDCAdapter;
* is made to log then a <code>LoggingEvent</code> instance is created. This
* instance is passed around to the different logback-classic components.
*
- * <p> Writers of logback-classic components such as appenders should be aware
- * of that some of the LoggingEvent fields are initialized lazily. Therefore, an
+ * <p>
+ * Writers of logback-classic components such as appenders should be aware of
+ * that some of the LoggingEvent fields are initialized lazily. Therefore, an
* appender wishing to output data to be later correctly read by a receiver,
* must initialize "lazy" fields prior to writing them out. See the
- * {@link #prepareForDeferredProcessing()} method for the exact list. </p>
+ * {@link #prepareForDeferredProcessing()} method for the exact list.
+ * </p>
*
* @author Ceki Gülcü
* @author Sébastien Pennec
@@ -45,7 +48,8 @@ public class LoggingEvent implements ILoggingEvent {
* Fully qualified name of the calling Logger class. This field does not
* survive serialization.
*
- * <p> Note that the getCallerInformation() method relies on this fact.
+ * <p>
+ * Note that the getCallerInformation() method relies on this fact.
*/
transient String fqnOfLoggerClass;
@@ -61,8 +65,10 @@ public class LoggingEvent implements ILoggingEvent {
/**
* Level of logging event.
*
- * <p> This field should not be accessed directly. You shoud use the {@link
- * #getLevel} method instead. </p>
+ * <p>
+ * This field should not be accessed directly. You shoud use the
+ * {@link #getLevel} method instead.
+ * </p>
*
*/
private transient Level level;
@@ -103,6 +109,16 @@ public class LoggingEvent implements ILoggingEvent {
this.message = message;
+ FormattingTuple ft = MessageFormatter.arrayFormat(message, argArray);
+ formattedMessage = ft.getMessage();
+
+ if (throwable == null) {
+ argumentArray = ft.getArgArray();
+ throwable = ft.getThrowable();
+ } else {
+ this.argumentArray = argArray;
+ }
+
if (throwable != null) {
this.throwableProxy = new ThrowableProxy(throwable);
LoggerContext lc = logger.getLoggerContext();
@@ -111,12 +127,9 @@ public class LoggingEvent implements ILoggingEvent {
}
}
- // bug 85 (we previously failed to set this.argumentArray)
- this.argumentArray = argArray;
-
timeStamp = System.currentTimeMillis();
- // the case is ugly but under the circumstances acceptable
+ // ugly but under the circumstances acceptable
LogbackMDCAdapter logbackMDCAdapter = (LogbackMDCAdapter) MDC
.getMDCAdapter();
mdcPropertyMap = logbackMDCAdapter.getPropertyMap();
@@ -154,9 +167,9 @@ public class LoggingEvent implements ILoggingEvent {
/**
* @param threadName
- * The threadName to set.
+ * The threadName to set.
* @throws IllegalStateException
- * If threadName has been already set.
+ * If threadName has been already set.
*/
public void setThreadName(String threadName) throws IllegalStateException {
if (this.threadName != null) {
@@ -188,9 +201,9 @@ public class LoggingEvent implements ILoggingEvent {
* This method should be called prior to serializing an event. It should also
* be called when using asynchronous or deferred logging.
*
- * <p> Note that due to performance concerns, this method does NOT extract
- * caller data. It is the responsibility of the caller to extract caller
- * information.
+ * <p>
+ * Note that due to performance concerns, this method does NOT extract caller
+ * data. It is the responsibility of the caller to extract caller information.
*/
public void prepareForDeferredProcessing() {
this.getFormattedMessage();
@@ -242,8 +255,10 @@ public class LoggingEvent implements ILoggingEvent {
* null at the time of its invocation, this method extracts location
* information. The collected information is cached for future use.
*
- * <p> Note that after serialization it is impossible to correctly extract
- * caller information. </p>
+ * <p>
+ * Note that after serialization it is impossible to correctly extract caller
+ * information.
+ * </p>
*/
public StackTraceElement[] getCallerData() {
if (callerDataArray == null) {
@@ -283,9 +298,9 @@ public class LoggingEvent implements ILoggingEvent {
if (formattedMessage != null) {
return formattedMessage;
}
-
if (argumentArray != null) {
- formattedMessage = MessageFormatter.arrayFormat(message, argumentArray);
+ formattedMessage = MessageFormatter.arrayFormat(message, argumentArray)
+ .getMessage();
} else {
formattedMessage = message;
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java
index 32c5708..c55b281 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java
@@ -73,7 +73,7 @@ public class LoggingEventVO implements ILoggingEvent, Serializable {
ledo.throwableProxy = ThrowableProxyVO.build(le.getThrowableProxy());
// add caller data only if it is there already
// fixes http://jira.qos.ch/browse/LBCLASSIC-145
- if(le.hasCallerData()) {
+ if (le.hasCallerData()) {
ledo.callerDataArray = le.getCallerData();
}
return ledo;
@@ -105,7 +105,8 @@ public class LoggingEventVO implements ILoggingEvent, Serializable {
}
if (argumentArray != null) {
- formattedMessage = MessageFormatter.arrayFormat(message, argumentArray);
+ formattedMessage = MessageFormatter.arrayFormat(message, argumentArray)
+ .getMessage();
} else {
formattedMessage = message;
}
@@ -137,8 +138,6 @@ public class LoggingEventVO implements ILoggingEvent, Serializable {
return timeStamp;
}
-
-
public long getContextBirthTime() {
return loggerContextVO.getBirthTime();
}
diff --git a/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
index c0ef94f..9e6ee66 100644
--- a/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
+++ b/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
@@ -30,7 +30,8 @@ import ch.qos.logback.core.util.StatusPrinter;
* The binding of {@link LoggerFactory} class with an actual instance of
* {@link ILoggerFactory} is performed using information returned by this class.
*
- * @author <a href="http://www.qos.ch/shop/products/log4jManual">Ceki Gülcü</a>
+ * @author <a href="http://www.qos.ch/shop/products/log4jManual">Ceki
+ * Gülcü</a>
*/
public class StaticLoggerBinder implements LoggerFactoryBinder {
@@ -56,8 +57,9 @@ public class StaticLoggerBinder implements LoggerFactoryBinder {
private boolean initialized = false;
private LoggerContext defaultLoggerContext = new LoggerContext();
- private final ContextSelectorStaticBinder contextSelectorBinder = ContextSelectorStaticBinder.getSingleton();
-
+ private final ContextSelectorStaticBinder contextSelectorBinder = ContextSelectorStaticBinder
+ .getSingleton();
+
private StaticLoggerBinder() {
defaultLoggerContext.setName(CoreConstants.DEFAULT_CONTEXT_NAME);
}
@@ -82,21 +84,18 @@ public class StaticLoggerBinder implements LoggerFactoryBinder {
try {
new ContextInitializer(defaultLoggerContext).autoConfig();
} catch (JoranException je) {
- Util.reportFailure("Failed to auto configure default logger context",
- je);
+ Util.report("Failed to auto configure default logger context", je);
}
StatusPrinter.printInCaseOfErrorsOrWarnings(defaultLoggerContext);
contextSelectorBinder.init(defaultLoggerContext, KEY);
initialized = true;
} catch (Throwable t) {
// we should never get here
- Util.reportFailure("Failed to instantiate ["
- + LoggerContext.class.getName() + "]", t);
+ Util.report("Failed to instantiate [" + LoggerContext.class.getName()
+ + "]", t);
}
}
-
-
public ILoggerFactory getLoggerFactory() {
if (!initialized) {
return defaultLoggerContext;
@@ -113,5 +112,4 @@ public class StaticLoggerBinder implements LoggerFactoryBinder {
return contextSelectorBinder.getContextSelector().getClass().getName();
}
-
}
diff --git a/logback-classic/src/test/input/joran/sift/lbclassic203.xml b/logback-classic/src/test/input/joran/sift/lbclassic203.xml
new file mode 100644
index 0000000..5db0eb8
--- /dev/null
+++ b/logback-classic/src/test/input/joran/sift/lbclassic203.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration>
+
+<configuration debug="true">
+
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+
+
+ <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
+
+ <discriminator>
+ <Key>userid</Key>
+ <defaultValue>smoke</defaultValue>
+ </discriminator>
+ <sift>
+ <appender name="list-${userid}"
+ class="ch.qos.logback.classic.issue.lbclassic203.InstanceCountingAppender" />
+ </sift>
+ </appender>
+
+ <root level="DEBUG">
+ <appender-ref ref="SIFT" />
+ </root>
+
+</configuration>
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/PackageTest.java
index f23dae9..2e79ccd 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/PackageTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/PackageTest.java
@@ -20,6 +20,8 @@ import org.junit.runners.Suite.SuiteClasses;
import ch.qos.logback.classic.issue.lbclassic135.lbclassic139.LB139_DeadlockTest;
@RunWith(Suite.class)
- at SuiteClasses(LB139_DeadlockTest.class)
+ at SuiteClasses( { LB139_DeadlockTest.class,
+ ch.qos.logback.classic.issue.lbclassic135.lbclassic139.PackageTest.class,
+ ch.qos.logback.classic.issue.lbclassic203.PackageTest.class })
public class PackageTest {
}
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/PackageTest.java
similarity index 84%
copy from logback-classic/src/test/java/ch/qos/logback/classic/issue/PackageTest.java
copy to logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/PackageTest.java
index f23dae9..23c6d27 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/PackageTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/PackageTest.java
@@ -11,14 +11,12 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
-package ch.qos.logback.classic.issue;
+package ch.qos.logback.classic.issue.lbclassic135.lbclassic139;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
-import ch.qos.logback.classic.issue.lbclassic135.lbclassic139.LB139_DeadlockTest;
-
@RunWith(Suite.class)
@SuiteClasses(LB139_DeadlockTest.class)
public class PackageTest {
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic154/LoggingAppender.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic154/LoggingAppender.java
index a95b2b5..4c69bb9 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic154/LoggingAppender.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic154/LoggingAppender.java
@@ -20,7 +20,6 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
/**
- *
* An appender which calls logback recursively
*
* @author Ralph Goers
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/ConcurrentSiftingTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/ConcurrentSiftingTest.java
index 0400413..4f67321 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/ConcurrentSiftingTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/ConcurrentSiftingTest.java
@@ -13,13 +13,52 @@
*/
package ch.qos.logback.classic.issue.lbclassic203;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
+import ch.qos.logback.classic.ClassicTestConstants;
+import ch.qos.logback.classic.Logger;
+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.contention.MultiThreadedHarness;
+import ch.qos.logback.core.contention.RunnableWithCounterAndDone;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.status.StatusChecker;
public class ConcurrentSiftingTest {
-
+ final static int THREAD_COUNT = 5;
+ static String FOLDER_PREFIX = ClassicTestConstants.JORAN_INPUT_PREFIX
+ + "sift/";
+
+ LoggerContext loggerContext = new LoggerContext();
+ protected Logger logger = loggerContext.getLogger(this.getClass().getName());
+ protected Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
+ StatusChecker sc = new StatusChecker(loggerContext);
+
+ int totalTestDuration = 50;
+ MultiThreadedHarness harness = new MultiThreadedHarness(totalTestDuration);
+ RunnableWithCounterAndDone[] runnableArray = buildRunnableArray();
+
+ protected void configure(String file) throws JoranException {
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(loggerContext);
+ jc.doConfigure(file);
+ }
+
+ RunnableWithCounterAndDone[] buildRunnableArray() {
+ RunnableWithCounterAndDone[] rArray = new RunnableWithCounterAndDone[THREAD_COUNT];
+ for (int i = 0; i < THREAD_COUNT; i++) {
+ rArray[i] = new LoggingRunnable(logger);
+ }
+ return rArray;
+ }
+
@Test
- public void test() {
- throw new IllegalStateException("");
+ public void concurrentAccess() throws JoranException, InterruptedException {
+ configure(FOLDER_PREFIX + "lbclassic203.xml");
+ harness.execute(runnableArray);
+ assertEquals(1, InstanceCountingAppender.INSTANCE_COUNT);
}
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/ConcurrentSiftingTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/InstanceCountingAppender.java
similarity index 62%
copy from logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/ConcurrentSiftingTest.java
copy to logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/InstanceCountingAppender.java
index 0400413..34e8133 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/ConcurrentSiftingTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/InstanceCountingAppender.java
@@ -13,13 +13,18 @@
*/
package ch.qos.logback.classic.issue.lbclassic203;
-import org.junit.Test;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.AppenderBase;
-
-public class ConcurrentSiftingTest {
+public class InstanceCountingAppender extends AppenderBase<ILoggingEvent> {
- @Test
- public void test() {
- throw new IllegalStateException("");
+ static public volatile int INSTANCE_COUNT = 0;
+
+ public InstanceCountingAppender() {
+ INSTANCE_COUNT++;
}
+
+ protected void append(ILoggingEvent e) {
+ }
+
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/LogbackRolloverTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/LogbackRolloverTest.java
deleted file mode 100644
index cc5f86f..0000000
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/LogbackRolloverTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package ch.qos.logback.classic.issue.lbclassic203;
-
-import java.util.Date;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LogbackRolloverTest extends Thread {
- private static Logger log = LoggerFactory
- .getLogger(LogbackRolloverTest.class);
- private static final int DEFAULT_THREAD_COUNT = 2;
- private static int threadcount = DEFAULT_THREAD_COUNT;
-
- public static void main(String[] args) {
- if (args.length > 0) {
- try {
- threadcount = Integer.parseInt(args[0]);
- } catch (Exception e) {
- System.out
- .println("Usage: LogbackRolloverTest [<thread count>] (defaults to "
- + DEFAULT_THREAD_COUNT + " threads)");
- System.exit(1);
- }
- }
- System.out.println("Logging from " + threadcount
- + (threadcount == 1 ? " thread" : " threads")
- + " (optional thread count parameter defaults to "
- + DEFAULT_THREAD_COUNT + ")");
-
- for (int i = 0; i < threadcount; i++) {
- new LogbackRolloverTest().start();
- }
- }
-
- public void run() {
- int count = 0;
- while (true) {
- doLog(count++);
- }
- }
-
- private void doLog(int count) {
- log.debug("The current date is " + new Date() + " the count is " + count);
- log.info("Info Message");
- log.warn("Warn Message");
- log.trace("Trace message");
- log.error("Error message");
- log.info("Info Message");
- log.warn("Warn Message");
- log.trace("Trace message");
- log.error("Error message");
- try {
- throw new Exception("throwing exception " + count
- + " to create a stack trace");
- } catch (Exception e) {
- log.error("caught " + e.toString(), e);
- }
- if (count % 10 == 0) {
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- log.error("Thread interrupted: " + e.toString(), e);
- }
- }
-
- }
-}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/PackageTest.java
similarity index 79%
copy from logback-classic/src/test/java/ch/qos/logback/classic/issue/PackageTest.java
copy to logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/PackageTest.java
index f23dae9..b009ca6 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/PackageTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/PackageTest.java
@@ -11,15 +11,13 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
-package ch.qos.logback.classic.issue;
+package ch.qos.logback.classic.issue.lbclassic203;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
-import ch.qos.logback.classic.issue.lbclassic135.lbclassic139.LB139_DeadlockTest;
-
@RunWith(Suite.class)
- at SuiteClasses(LB139_DeadlockTest.class)
+ at SuiteClasses(ConcurrentSiftingTest.class)
public class PackageTest {
}
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java
index 1d05659..0b72c21 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java
@@ -1,6 +1,6 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ * Copyright (C) 1999-2010, 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
@@ -41,14 +41,14 @@ import ch.qos.logback.core.util.StatusPrinter;
public class SiftingAppenderTest {
- static String PREFIX = ClassicTestConstants.JORAN_INPUT_PREFIX + "sift/";
+ static String SIFT_FOLDER_PREFIX = ClassicTestConstants.JORAN_INPUT_PREFIX + "sift/";
LoggerContext loggerContext = new LoggerContext();
Logger logger = loggerContext.getLogger(this.getClass().getName());
Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
StatusChecker sc = new StatusChecker(loggerContext);
- void configure(String file) throws JoranException {
+ protected void configure(String file) throws JoranException {
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(loggerContext);
jc.doConfigure(file);
@@ -56,7 +56,7 @@ public class SiftingAppenderTest {
@Test
public void unsetDefaultValueProperty() throws JoranException {
- configure(PREFIX + "unsetDefaultValueProperty.xml");
+ configure(SIFT_FOLDER_PREFIX + "unsetDefaultValueProperty.xml");
logger.debug("hello");
SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT");
assertFalse(sa.isStarted());
@@ -64,7 +64,7 @@ public class SiftingAppenderTest {
@Test
public void smoke() throws JoranException {
- configure(PREFIX + "smoke.xml");
+ configure(SIFT_FOLDER_PREFIX + "smoke.xml");
logger.debug("smoke");
long timestamp = 0;
SiftingAppender ha = (SiftingAppender) root.getAppender("SIFT");
@@ -78,7 +78,7 @@ public class SiftingAppenderTest {
@Test
public void zeroNesting() throws JoranException {
- configure(PREFIX + "zeroNesting.xml");
+ configure(SIFT_FOLDER_PREFIX + "zeroNesting.xml");
logger.debug("hello");
logger.debug("hello");
logger.debug("hello");
@@ -100,7 +100,7 @@ public class SiftingAppenderTest {
@Test
public void multipleNesting() throws JoranException {
- configure(PREFIX + "multipleNesting.xml");
+ configure(SIFT_FOLDER_PREFIX + "multipleNesting.xml");
logger.debug("hello");
logger.debug("hello");
logger.debug("hello");
@@ -119,7 +119,7 @@ public class SiftingAppenderTest {
@Test
public void defaultLayoutRule() throws JoranException {
- configure(PREFIX + "defaultLayoutRule.xml");
+ configure(SIFT_FOLDER_PREFIX + "defaultLayoutRule.xml");
logger.debug("hello");
long timestamp = 0;
SiftingAppender ha = (SiftingAppender) root.getAppender("SIFT");
@@ -135,7 +135,7 @@ public class SiftingAppenderTest {
@Test
public void testWholeCycle() throws JoranException {
String mdcKey = "cycle";
- configure(PREFIX + "completeCycle.xml");
+ configure(SIFT_FOLDER_PREFIX + "completeCycle.xml");
MDC.put(mdcKey, "a");
logger.debug("smoke");
long timestamp = System.currentTimeMillis();
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java
index 9946aab..68d17e3 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java
@@ -28,11 +28,9 @@ import ch.qos.logback.classic.Level;
* A read/write and serializable implementation of {@link ILoggingEvent}.
*
* @author Ceki Gülcü
-
*/
public class PubLoggingEventVO implements ILoggingEvent, Serializable {
-
private static final long serialVersionUID = -3385765861078946218L;
private static final int NULL_ARGUMENT_ARRAY = -1;
@@ -55,8 +53,6 @@ public class PubLoggingEventVO implements ILoggingEvent, Serializable {
public Map<String, String> mdcPropertyMap;
public long timeStamp;
-
-
public String getThreadName() {
return threadName;
}
@@ -83,7 +79,8 @@ public class PubLoggingEventVO implements ILoggingEvent, Serializable {
}
if (argumentArray != null) {
- formattedMessage = MessageFormatter.arrayFormat(message, argumentArray);
+ formattedMessage = MessageFormatter.arrayFormat(message, argumentArray)
+ .getMessage();
} else {
formattedMessage = message;
}
@@ -115,8 +112,6 @@ public class PubLoggingEventVO implements ILoggingEvent, Serializable {
return timeStamp;
}
-
-
public long getContextBirthTime() {
return loggerContextVO.getBirthTime();
}
@@ -222,7 +217,7 @@ public class PubLoggingEventVO implements ILoggingEvent, Serializable {
return false;
return true;
}
-
+
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(timeStamp);
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 865f040..87a62b8 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
@@ -106,11 +106,13 @@ public abstract class SiftingAppenderBase<E> extends
int nopaWarningCount = 0;
NOPAppender<E> buildNOPAppender(String discriminatingValue) {
- NOPAppender<E> nopa = new NOPAppender<E>();
if(nopaWarningCount < CoreConstants.MAX_ERROR_COUNT) {
nopaWarningCount++;
addError("Failed to build an appender for discriminating value ["+discriminatingValue+"]");
}
+ NOPAppender<E> nopa = new NOPAppender<E>();
+ nopa.setContext(context);
+ nopa.start();
return nopa;
}
diff --git a/logback-examples/src/main/resources/setClasspath.cmd b/logback-examples/src/main/resources/setClasspath.cmd
index 9b42ad0..9c7924a 100644
--- a/logback-examples/src/main/resources/setClasspath.cmd
+++ b/logback-examples/src/main/resources/setClasspath.cmd
@@ -10,5 +10,4 @@ set CLASSPATH=%CLASSPATH%;%LB_HOME%/logback-core-${project.version}.jar
set CLASSPATH=%CLASSPATH%;%LB_HOME%/logback-examples/logback-examples-${project.version}.jar
set CLASSPATH=%CLASSPATH%;%LB_HOME%/logback-examples/lib/slf4j-api-${slf4j.version}.jar
-
REM echo %CLASSPATH%
diff --git a/pom.xml b/pom.xml
index 4c24b04..eb436ae 100755
--- a/pom.xml
+++ b/pom.xml
@@ -43,7 +43,7 @@
<properties>
<!-- slf4j.version property is used below, in
logback-classic/pom.xml and in setClasspath.cmd -->
- <slf4j.version>1.5.11</slf4j.version>
+ <slf4j.version>1.6.0-RC0</slf4j.version>
<consolePlugin.version>1.1.0</consolePlugin.version>
</properties>
-----------------------------------------------------------------------
Summary of changes:
logback-classic/pom.xml | 2 +-
.../main/java/ch/qos/logback/classic/Logger.java | 70 +++++++++++---------
.../ch/qos/logback/classic/spi/LoggingEvent.java | 53 ++++++++++-----
.../ch/qos/logback/classic/spi/LoggingEventVO.java | 7 +-
.../java/org/slf4j/impl/StaticLoggerBinder.java | 18 ++---
.../joran/sift/{smoke.xml => lbclassic203.xml} | 5 +-
.../ch/qos/logback/classic/issue/PackageTest.java | 4 +-
.../lbclassic135/lbclassic139}/PackageTest.java | 5 +-
.../issue/lbclassic154/LoggingAppender.java | 1 -
.../issue/lbclassic203/ConcurrentSiftingTest.java | 45 ++++++++++++-
...tingTest.java => InstanceCountingAppender.java} | 17 +++--
.../issue/lbclassic203/LogbackRolloverTest.java | 67 -------------------
.../classic/issue/lbclassic203}/PackageTest.java | 7 +-
.../logback/classic/sift/SiftingAppenderTest.java | 18 +++---
.../qos/logback/classic/spi/PubLoggingEventVO.java | 11 +--
.../qos/logback/core/sift/SiftingAppenderBase.java | 4 +-
.../src/main/resources/setClasspath.cmd | 1 -
pom.xml | 2 +-
18 files changed, 165 insertions(+), 172 deletions(-)
copy logback-classic/src/test/input/joran/sift/{smoke.xml => lbclassic203.xml} (71%)
copy logback-classic/src/test/java/ch/qos/logback/classic/{joran/conditional => issue/lbclassic135/lbclassic139}/PackageTest.java (85%)
copy logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/{ConcurrentSiftingTest.java => InstanceCountingAppender.java} (62%)
delete mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203/LogbackRolloverTest.java
copy {logback-core/src/test/java/ch/qos/logback/core/helpers => logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic203}/PackageTest.java (86%)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list