diff -Nru logback-1.1.9/debian/changelog logback-1.2.3/debian/changelog --- logback-1.1.9/debian/changelog 2017-11-27 02:59:24.000000000 +0000 +++ logback-1.2.3/debian/changelog 2017-12-01 03:21:55.000000000 +0000 @@ -1,3 +1,26 @@ +logback (1:1.2.3-2) unstable; urgency=medium + + * Team upload. + * Freshen debian/copyright for current upstream + * Bump Standards-Version to 4.1.2 + * Add myself to Uploaders + * Use https for Homepage URL + * Upload to unstable after building r-deps. + + -- tony mancill Thu, 30 Nov 2017 19:21:55 -0800 + +logback (1:1.2.3-1) experimental; urgency=medium + + * Team upload. + * New upstream version 1.2.3 + * Disable and clean-up unused patches + * Add build-dep on libgmavenplus-java + * No longer rename javax.servlet-api artifact in debian/maven.rules + * Add ant-junit and maven-cal10n-plugin to maven.ignoreRules + * Update groupId of org.hsqldb in maven.ignoreRules + + -- tony mancill Tue, 28 Nov 2017 19:52:38 -0800 + logback (1:1.1.9-5) unstable; urgency=medium * Team upload. diff -Nru logback-1.1.9/debian/control logback-1.2.3/debian/control --- logback-1.1.9/debian/control 2017-11-27 02:59:24.000000000 +0000 +++ logback-1.2.3/debian/control 2017-12-01 03:21:55.000000000 +0000 @@ -2,11 +2,13 @@ Section: java Priority: optional Maintainer: Debian Java Maintainers -Uploaders: Damien Raude-Morvan +Uploaders: Damien Raude-Morvan , + tony mancill Build-Depends: debhelper (>= 10), default-jdk, groovy, libgeronimo-jms-1.1-spec-java, + libgmavenplus-java, libjanino-java (>= 2.6.0), libjansi-java, libmail-java, @@ -18,10 +20,10 @@ libjetty9-java, libtomcat8-java, maven-debian-helper -Standards-Version: 4.1.1 +Standards-Version: 4.1.2 Vcs-Git: https://anonscm.debian.org/git/pkg-java/logback.git Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/logback.git -Homepage: http://logback.qos.ch +Homepage: https://logback.qos.ch Package: liblogback-java Architecture: all diff -Nru logback-1.1.9/debian/copyright logback-1.2.3/debian/copyright --- logback-1.1.9/debian/copyright 2017-11-27 02:59:24.000000000 +0000 +++ logback-1.2.3/debian/copyright 2017-12-01 03:21:55.000000000 +0000 @@ -1,10 +1,10 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Logback Upstream-Contact: Logback developpers -Source: http://logback.qos.ch/dist/ +Source: https://logback.qos.ch/dist/ Files: * -Copyright: 2000-2015, QOS.ch +Copyright: 2000-2017, QOS.ch License: LGPL-2.1 or EPL-1.0 Comment: This program and the accompanying materials are dual-licensed under @@ -16,14 +16,9 @@ under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. -Files: logback-classic/src/test/java/org/slf4j/test_osgi/FrameworkErrorListener.java - logback-classic/src/test/java/org/slf4j/test_osgi/FelixHost.java - logback-classic/src/test/java/integrator/Activator.java -Copyright: 2004-2015, QOS.ch -License: BSD-X11 - Files: debian/* Copyright: 2008-2011, Damien Raude-Morvan + 2017 tony mancill License: LGPL-2.1 or BSD-X11 License: BSD-X11 diff -Nru logback-1.1.9/debian/maven.ignoreRules logback-1.2.3/debian/maven.ignoreRules --- logback-1.1.9/debian/maven.ignoreRules 2017-11-27 02:59:24.000000000 +0000 +++ logback-1.2.3/debian/maven.ignoreRules 2017-12-01 03:21:55.000000000 +0000 @@ -2,10 +2,11 @@ com.h2database h2 * * * * com.icegreen greenmail * * * * dom4j dom4j * * * * -hsqldb hsqldb * * * * +org.hsqldb hsqldb * * * * joda-time joda-time * * * * junit junit * * * * log4j log4j * * * * +org.apache.ant ant-junit * * * * org.apache.felix org.apache.felix.main * * * * org.apache.maven.plugins maven-assembly-plugin * * * * org.apache.maven.plugins maven-compiler-plugin * * * * @@ -25,3 +26,4 @@ org.subethamail subethasmtp * * * * postgresql postgresql * * * * mysql mysql-connector-java * * * * +ch.qos.cal10n.plugins maven-cal10n-plugin * * * * diff -Nru logback-1.1.9/debian/maven.rules logback-1.2.3/debian/maven.rules --- logback-1.1.9/debian/maven.rules 2017-11-27 02:59:24.000000000 +0000 +++ logback-1.2.3/debian/maven.rules 2017-12-01 03:21:55.000000000 +0000 @@ -1,5 +1,5 @@ junit junit jar s/4\..*/4.x/ -javax.servlet s/servlet-api/javax.servlet-api/ jar s/.*/3.1/ * * +javax.servlet javax.servlet-api * s/.*/3.1/ * * javax.mail s/mail/javax.mail-api * s/.*/debian/ * * org.apache.tomcat tomcat-catalina * s/.*/8.x/ org.apache.tomcat tomcat-coyote * s/.*/8.x/ diff -Nru logback-1.1.9/debian/patches/01-compile-groovy.patch logback-1.2.3/debian/patches/01-compile-groovy.patch --- logback-1.1.9/debian/patches/01-compile-groovy.patch 2017-11-27 02:59:24.000000000 +0000 +++ logback-1.2.3/debian/patches/01-compile-groovy.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -Description: Compile logback-classic with the groovyc Ant task instead of groovy-eclipse-compiler (not yet in Debian) -Author: Emmanuel Bourg -Forwarded: not-needed ---- a/logback-classic/pom.xml -+++ b/logback-classic/pom.xml -@@ -236,48 +236,24 @@ - org.apache.maven.plugins - maven-antrun-plugin - 1.7 -- -- -- org.apache.ant -- ant-junit -- 1.8.1 -- -- -- junit -- junit -- ${junit.version} -- -- -- - - -- ant-osgi-test -- package -- -- -- -- -- -- -- -- -+ compile-groovy -+ process-resources - - run - -- -- -- -- ant-integration-test -- package - -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ - -- -- run -- - - - diff -Nru logback-1.1.9/debian/patches/03-servlet-3.1.patch logback-1.2.3/debian/patches/03-servlet-3.1.patch --- logback-1.1.9/debian/patches/03-servlet-3.1.patch 2017-11-27 02:59:24.000000000 +0000 +++ logback-1.2.3/debian/patches/03-servlet-3.1.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -Author: Apollon Oikonomopoulos -Description: Patch logback-access to comply with the servlet 3.1 API - This is a partial backport of upstream commit 9ad7cc6141. -Forwarded: not-needed (fixed upstream) -Last-Update: 2017-03-01 ---- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java -+++ b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java -@@ -18,6 +18,7 @@ - import java.io.IOException; - import java.io.InputStream; - -+import javax.servlet.ReadListener; - import javax.servlet.ServletInputStream; - import javax.servlet.http.HttpServletRequest; - -@@ -71,4 +72,19 @@ - byte[] getInputBuffer() { - return inputBuffer; - } -+ -+ @Override -+ public boolean isFinished() { -+ throw new RuntimeException("Not yet implemented"); -+ } -+ -+ @Override -+ public boolean isReady() { -+ throw new RuntimeException("Not yet implemented"); -+ } -+ -+ @Override -+ public void setReadListener(ReadListener listener) { -+ throw new RuntimeException("Not yet implemented"); -+ } - } ---- a/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java -+++ b/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java -@@ -16,6 +16,7 @@ - import java.io.ByteArrayOutputStream; - import java.io.IOException; - -+import javax.servlet.WriteListener; - import javax.servlet.ServletOutputStream; - import javax.servlet.ServletResponse; - -@@ -82,4 +83,14 @@ - underlyingStream.flush(); - baosCopy.flush(); - } -+ -+ @Override -+ public boolean isReady() { -+ throw new RuntimeException("Not yet implemented"); -+ } -+ -+ @Override -+ public void setWriteListener(WriteListener listener) { -+ throw new RuntimeException("Not yet implemented"); -+ } - } ---- 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 -@@ -328,7 +328,6 @@ - return aai.detachAppender(name); - } - -- @Override - public String getInfo() { - return "Logback's implementation of ValveBase"; - } diff -Nru logback-1.1.9/debian/patches/CVE-2017-5929-part2.patch logback-1.2.3/debian/patches/CVE-2017-5929-part2.patch --- logback-1.1.9/debian/patches/CVE-2017-5929-part2.patch 2017-11-27 02:59:24.000000000 +0000 +++ logback-1.2.3/debian/patches/CVE-2017-5929-part2.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,390 +0,0 @@ -From: Markus Koschany -Date: Tue, 4 Apr 2017 14:22:43 +0200 -Subject: CVE-2017-5929-part2 - -This is part2 to fix CVE-2017-5929 - -Origin: https://github.com/qos-ch/logback/commit/979b042cb1f0b4c1e5869ccc8912e68c39f769f9 -Origin: https://github.com/qos-ch/logback/commit/7fbea6127fa98fc48368ca5e8540eefe0e60cec5 -Origin: https://github.com/qos-ch/logback/commit/3b4f605454534b304770eeee3cb343521fcd6968 ---- - .../access/net/HardenedAccessEventInputStream.java | 15 ++++++ - .../java/ch/qos/logback/access/net/SocketNode.java | 11 ++--- - .../ch/qos/logback/classic/net/SocketAppender.java | 2 - - .../ch/qos/logback/classic/net/SocketNode.java | 14 +++--- - .../server/HardenedLoggingEventInputStream.java | 56 ++++++++++++++++++++++ - .../server/LogbackClassicSerializationHelper.java | 28 ----------- - .../net/server/RemoteAppenderStreamClient.java | 10 ++-- - .../core/net/HardenedObjectInputStream.java | 47 +++++++++++++----- - 8 files changed, 123 insertions(+), 60 deletions(-) - create mode 100644 logback-access/src/main/java/ch/qos/logback/access/net/HardenedAccessEventInputStream.java - create mode 100644 logback-classic/src/main/java/ch/qos/logback/classic/net/server/HardenedLoggingEventInputStream.java - delete mode 100644 logback-classic/src/main/java/ch/qos/logback/classic/net/server/LogbackClassicSerializationHelper.java - -diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/HardenedAccessEventInputStream.java b/logback-access/src/main/java/ch/qos/logback/access/net/HardenedAccessEventInputStream.java -new file mode 100644 -index 0000000..c0ba6b0 ---- /dev/null -+++ b/logback-access/src/main/java/ch/qos/logback/access/net/HardenedAccessEventInputStream.java -@@ -0,0 +1,15 @@ -+package ch.qos.logback.access.net; -+ -+import java.io.IOException; -+import java.io.InputStream; -+ -+import ch.qos.logback.access.spi.AccessEvent; -+import ch.qos.logback.core.net.HardenedObjectInputStream; -+ -+public class HardenedAccessEventInputStream extends HardenedObjectInputStream { -+ -+ public HardenedAccessEventInputStream(InputStream in) throws IOException { -+ super(in, new String[] {AccessEvent.class.getName(), String[].class.getName()}); -+ } -+ -+} -diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java b/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java -index e164774..aeb7b14 100644 ---- a/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java -+++ b/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java -@@ -15,7 +15,6 @@ package ch.qos.logback.access.net; - - import java.io.BufferedInputStream; - import java.io.IOException; --import java.io.ObjectInputStream; - import java.net.Socket; - - import ch.qos.logback.access.spi.AccessContext; -@@ -42,15 +41,15 @@ public class SocketNode implements Runnable { - - Socket socket; - AccessContext context; -- ObjectInputStream ois; -+ HardenedAccessEventInputStream hardenedOIS; - - public SocketNode(Socket socket, AccessContext context) { - this.socket = socket; - this.context = context; - try { -- ois = new ObjectInputStream(new BufferedInputStream(socket.getInputStream())); -+ hardenedOIS = new HardenedAccessEventInputStream(new BufferedInputStream(socket.getInputStream())); - } catch (Exception e) { -- System.out.println("Could not open ObjectInputStream to " + socket + e); -+ System.out.println("Could not open HardenedObjectInputStream to " + socket + e); - } - } - -@@ -61,7 +60,7 @@ public class SocketNode implements Runnable { - try { - while (true) { - // read an event from the wire -- event = (IAccessEvent) ois.readObject(); -+ event = (IAccessEvent) hardenedOIS.readObject(); - // check that the event should be logged - if (context.getFilterChainDecision(event) == FilterReply.DENY) { - break; -@@ -81,7 +80,7 @@ public class SocketNode implements Runnable { - } - - try { -- ois.close(); -+ hardenedOIS.close(); - } catch (Exception e) { - System.out.println("Could not close connection." + e); - } -diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java -index 82518c7..0590cae 100644 ---- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java -+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java -@@ -14,8 +14,6 @@ - // Contributors: Dan MacDonald - package ch.qos.logback.classic.net; - --import java.net.InetAddress; -- - import ch.qos.logback.classic.spi.ILoggingEvent; - import ch.qos.logback.core.net.AbstractSocketAppender; - import ch.qos.logback.core.spi.PreSerializationTransformer; -diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java -index 4c01cbe..8faf6a6 100644 ---- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java -+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java -@@ -15,13 +15,13 @@ package ch.qos.logback.classic.net; - - import java.io.BufferedInputStream; - import java.io.IOException; --import java.io.ObjectInputStream; - import java.net.Socket; - import java.net.SocketAddress; - - import ch.qos.logback.classic.Logger; - - import ch.qos.logback.classic.LoggerContext; -+import ch.qos.logback.classic.net.server.HardenedLoggingEventInputStream; - import ch.qos.logback.classic.spi.ILoggingEvent; - - // Contributors: Moses Hohman -@@ -44,7 +44,7 @@ public class SocketNode implements Runnable { - - Socket socket; - LoggerContext context; -- ObjectInputStream ois; -+ HardenedLoggingEventInputStream hardenedLoggingEventInputStream; - SocketAddress remoteSocketAddress; - - Logger logger; -@@ -68,7 +68,7 @@ public class SocketNode implements Runnable { - public void run() { - - try { -- ois = new ObjectInputStream(new BufferedInputStream(socket.getInputStream())); -+ hardenedLoggingEventInputStream = new HardenedLoggingEventInputStream(new BufferedInputStream(socket.getInputStream())); - } catch (Exception e) { - logger.error("Could not open ObjectInputStream to " + socket, e); - closed = true; -@@ -80,7 +80,7 @@ public class SocketNode implements Runnable { - try { - while (!closed) { - // read an event from the wire -- event = (ILoggingEvent) ois.readObject(); -+ event = (ILoggingEvent) hardenedLoggingEventInputStream.readObject(); - // get a logger from the hierarchy. The name of the logger is taken to - // be the name contained in the event. - remoteLogger = context.getLogger(event.getLoggerName()); -@@ -110,13 +110,13 @@ public class SocketNode implements Runnable { - return; - } - closed = true; -- if (ois != null) { -+ if (hardenedLoggingEventInputStream != null) { - try { -- ois.close(); -+ hardenedLoggingEventInputStream.close(); - } catch (IOException e) { - logger.warn("Could not close connection.", e); - } finally { -- ois = null; -+ hardenedLoggingEventInputStream = null; - } - } - } -diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/HardenedLoggingEventInputStream.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/HardenedLoggingEventInputStream.java -new file mode 100644 -index 0000000..522a30f ---- /dev/null -+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/HardenedLoggingEventInputStream.java -@@ -0,0 +1,56 @@ -+package ch.qos.logback.classic.net.server; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.util.ArrayList; -+import java.util.List; -+ -+import org.slf4j.helpers.BasicMarker; -+ -+import ch.qos.logback.classic.Level; -+import ch.qos.logback.classic.Logger; -+import ch.qos.logback.classic.spi.ClassPackagingData; -+import ch.qos.logback.classic.spi.IThrowableProxy; -+import ch.qos.logback.classic.spi.LoggerContextVO; -+import ch.qos.logback.classic.spi.LoggerRemoteView; -+import ch.qos.logback.classic.spi.LoggingEventVO; -+import ch.qos.logback.classic.spi.StackTraceElementProxy; -+import ch.qos.logback.classic.spi.ThrowableProxy; -+import ch.qos.logback.classic.spi.ThrowableProxyVO; -+import ch.qos.logback.core.net.HardenedObjectInputStream; -+ -+public class HardenedLoggingEventInputStream extends HardenedObjectInputStream { -+ -+ static final String ARRAY_PREFIX = "[L"; -+ -+ static public List getWhilelist() { -+ List whitelist = new ArrayList(); -+ whitelist.add(LoggingEventVO.class.getName()); -+ whitelist.add(LoggerContextVO.class.getName()); -+ whitelist.add(LoggerRemoteView.class.getName()); -+ whitelist.add(ThrowableProxyVO.class.getName()); -+ whitelist.add(BasicMarker.class.getName()); -+ whitelist.add(Level.class.getName()); -+ whitelist.add(Logger.class.getName()); -+ whitelist.add(StackTraceElement.class.getName()); -+ whitelist.add(StackTraceElement[].class.getName()); -+ whitelist.add(ThrowableProxy.class.getName()); -+ whitelist.add(ThrowableProxy[].class.getName()); -+ whitelist.add(IThrowableProxy.class.getName()); -+ whitelist.add(IThrowableProxy[].class.getName()); -+ whitelist.add(StackTraceElementProxy.class.getName()); -+ whitelist.add(StackTraceElementProxy[].class.getName()); -+ whitelist.add(ClassPackagingData.class.getName()); -+ -+ return whitelist; -+ } -+ -+ public HardenedLoggingEventInputStream(InputStream is) throws IOException { -+ super(is, getWhilelist()); -+ } -+ -+ public HardenedLoggingEventInputStream(InputStream is, List additionalAuthorizedClasses) throws IOException { -+ this(is); -+ super.addToWhitelist(additionalAuthorizedClasses); -+ } -+} -diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/LogbackClassicSerializationHelper.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/LogbackClassicSerializationHelper.java -deleted file mode 100644 -index 00a974f..0000000 ---- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/LogbackClassicSerializationHelper.java -+++ /dev/null -@@ -1,28 +0,0 @@ --package ch.qos.logback.classic.net.server; -- --import java.util.ArrayList; --import java.util.List; -- --import org.slf4j.helpers.BasicMarker; -- --import ch.qos.logback.classic.Logger; --import ch.qos.logback.classic.spi.LoggerContextVO; --import ch.qos.logback.classic.spi.LoggingEventVO; --import ch.qos.logback.classic.spi.ThrowableProxyVO; -- --public class LogbackClassicSerializationHelper { -- -- -- -- static public List getWhilelist() { -- List whitelist = new ArrayList(); -- whitelist.add(LoggingEventVO.class.getName()); -- whitelist.add(LoggerContextVO.class.getName()); -- whitelist.add(ThrowableProxyVO.class.getName()); -- whitelist.add(StackTraceElement.class.getName()); -- whitelist.add(BasicMarker.class.getName()); -- whitelist.add(BasicMarker.class.getName()); -- whitelist.add(Logger.class.getName()); -- return whitelist; -- } --} -diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java -index 5be7e24..71e1b0b 100644 ---- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java -+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java -@@ -16,12 +16,12 @@ package ch.qos.logback.classic.net.server; - import java.io.EOFException; - import java.io.IOException; - import java.io.InputStream; --import java.io.ObjectInputStream; - import java.net.Socket; - - import ch.qos.logback.classic.Logger; - import ch.qos.logback.classic.LoggerContext; - import ch.qos.logback.classic.spi.ILoggingEvent; -+import ch.qos.logback.core.net.HardenedObjectInputStream; - import ch.qos.logback.core.util.CloseUtil; - - /** -@@ -87,7 +87,7 @@ class RemoteAppenderStreamClient implements RemoteAppenderClient { - */ - public void run() { - logger.info(this + ": connected"); -- ObjectInputStream ois = null; -+ HardenedObjectInputStream ois = null; - try { - ois = createObjectInputStream(); - while (true) { -@@ -120,11 +120,11 @@ class RemoteAppenderStreamClient implements RemoteAppenderClient { - } - } - -- private ObjectInputStream createObjectInputStream() throws IOException { -+ private HardenedObjectInputStream createObjectInputStream() throws IOException { - if (inputStream != null) { -- return new ObjectInputStream(inputStream); -+ return new HardenedLoggingEventInputStream(inputStream); - } -- return new ObjectInputStream(socket.getInputStream()); -+ return new HardenedLoggingEventInputStream(socket.getInputStream()); - } - - /** -diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java b/logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java -index 439e2bd..d1b7301 100644 ---- a/logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java -+++ b/logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java -@@ -6,43 +6,66 @@ import java.io.InvalidClassException; - import java.io.ObjectInputStream; - import java.io.ObjectStreamClass; - import java.util.ArrayList; --import java.util.Collections; - import java.util.List; - - /** -+ * HardenedObjectInputStream restricts the set of classes that can be deserialized to a set of -+ * explicitly whitelisted classes. This prevents certain type of attacks from being successful. -+ * -+ *

It is assumed that classes in the "java.lang" and "java.util" packages are -+ * always authorized.

- * - * @author Ceki Gülcü - * @since 1.2.0 - */ - public class HardenedObjectInputStream extends ObjectInputStream { - -- List whitelistedClassNames; -- String[] javaPackages = new String[] {"java.lang", "java.util"}; -- -- public HardenedObjectInputStream(InputStream in, List whilelist) throws IOException { -+ final List whitelistedClassNames; -+ final static String[] JAVA_PACKAGES = new String[] { "java.lang", "java.util" }; -+ -+ public HardenedObjectInputStream(InputStream in, String[] whilelist) throws IOException { - super(in); -- this.whitelistedClassNames = Collections.synchronizedList(new ArrayList(whilelist)); -+ -+ this.whitelistedClassNames = new ArrayList(); -+ if (whilelist != null) { -+ for (int i = 0; i < whilelist.length; i++) { -+ this.whitelistedClassNames.add(whilelist[i]); -+ } -+ } -+ } -+ -+ public HardenedObjectInputStream(InputStream in, List whitelist) throws IOException { -+ super(in); -+ -+ this.whitelistedClassNames = new ArrayList(); -+ this.whitelistedClassNames.addAll(whitelist); - } - - @Override - protected Class resolveClass(ObjectStreamClass anObjectStreamClass) throws IOException, ClassNotFoundException { -+ - String incomingClassName = anObjectStreamClass.getName(); -- if(!isWhitelisted(incomingClassName)) { -+ -+ if (!isWhitelisted(incomingClassName)) { - throw new InvalidClassException("Unauthorized deserialization attempt", anObjectStreamClass.getName()); - } -- -+ - return super.resolveClass(anObjectStreamClass); - } - - private boolean isWhitelisted(String incomingClassName) { -- for(int i = 0; i < javaPackages.length; i++) { -- if(incomingClassName.startsWith(javaPackages[i])) -+ for (int i = 0; i < JAVA_PACKAGES.length; i++) { -+ if (incomingClassName.startsWith(JAVA_PACKAGES[i])) - return true; - } -- for(String className: whitelistedClassNames) { -- if(incomingClassName.equals(className)) -+ for (String whiteListed : whitelistedClassNames) { -+ if (incomingClassName.equals(whiteListed)) - return true; - } - return false; - } -+ -+ protected void addToWhitelist(List additionalAuthorizedClasses) { -+ whitelistedClassNames.addAll(additionalAuthorizedClasses); -+ } - } diff -Nru logback-1.1.9/debian/patches/CVE-2017-5929.patch logback-1.2.3/debian/patches/CVE-2017-5929.patch --- logback-1.1.9/debian/patches/CVE-2017-5929.patch 2017-11-27 02:59:24.000000000 +0000 +++ logback-1.2.3/debian/patches/CVE-2017-5929.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -From: Markus Koschany -Date: Tue, 28 Mar 2017 14:51:54 +0200 -Subject: CVE-2017-5929 - -Bug-Debian: https://bugs.debian.org/857343 -Origin: https://github.com/qos-ch/logback/commit/f46044b805bca91efe5fd6afe52257cd02f775f8 ---- - .../logback/classic/net/SimpleSocketServer.java | 1 - - .../server/LogbackClassicSerializationHelper.java | 28 +++++++++++++ - .../core/net/HardenedObjectInputStream.java | 48 ++++++++++++++++++++++ - 3 files changed, 76 insertions(+), 1 deletion(-) - create mode 100644 logback-classic/src/main/java/ch/qos/logback/classic/net/server/LogbackClassicSerializationHelper.java - create mode 100644 logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java - -diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java -index 13bf6f7..17fda2a 100644 ---- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java -+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java -@@ -14,7 +14,6 @@ - package ch.qos.logback.classic.net; - - import java.io.IOException; --import java.lang.reflect.Constructor; - import java.net.ServerSocket; - import java.net.Socket; - import java.util.ArrayList; -diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/LogbackClassicSerializationHelper.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/LogbackClassicSerializationHelper.java -new file mode 100644 -index 0000000..00a974f ---- /dev/null -+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/LogbackClassicSerializationHelper.java -@@ -0,0 +1,28 @@ -+package ch.qos.logback.classic.net.server; -+ -+import java.util.ArrayList; -+import java.util.List; -+ -+import org.slf4j.helpers.BasicMarker; -+ -+import ch.qos.logback.classic.Logger; -+import ch.qos.logback.classic.spi.LoggerContextVO; -+import ch.qos.logback.classic.spi.LoggingEventVO; -+import ch.qos.logback.classic.spi.ThrowableProxyVO; -+ -+public class LogbackClassicSerializationHelper { -+ -+ -+ -+ static public List getWhilelist() { -+ List whitelist = new ArrayList(); -+ whitelist.add(LoggingEventVO.class.getName()); -+ whitelist.add(LoggerContextVO.class.getName()); -+ whitelist.add(ThrowableProxyVO.class.getName()); -+ whitelist.add(StackTraceElement.class.getName()); -+ whitelist.add(BasicMarker.class.getName()); -+ whitelist.add(BasicMarker.class.getName()); -+ whitelist.add(Logger.class.getName()); -+ return whitelist; -+ } -+} -diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java b/logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java -new file mode 100644 -index 0000000..439e2bd ---- /dev/null -+++ b/logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java -@@ -0,0 +1,48 @@ -+package ch.qos.logback.core.net; -+ -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.InvalidClassException; -+import java.io.ObjectInputStream; -+import java.io.ObjectStreamClass; -+import java.util.ArrayList; -+import java.util.Collections; -+import java.util.List; -+ -+/** -+ * -+ * @author Ceki Gülcü -+ * @since 1.2.0 -+ */ -+public class HardenedObjectInputStream extends ObjectInputStream { -+ -+ List whitelistedClassNames; -+ String[] javaPackages = new String[] {"java.lang", "java.util"}; -+ -+ public HardenedObjectInputStream(InputStream in, List whilelist) throws IOException { -+ super(in); -+ this.whitelistedClassNames = Collections.synchronizedList(new ArrayList(whilelist)); -+ } -+ -+ @Override -+ protected Class resolveClass(ObjectStreamClass anObjectStreamClass) throws IOException, ClassNotFoundException { -+ String incomingClassName = anObjectStreamClass.getName(); -+ if(!isWhitelisted(incomingClassName)) { -+ throw new InvalidClassException("Unauthorized deserialization attempt", anObjectStreamClass.getName()); -+ } -+ -+ return super.resolveClass(anObjectStreamClass); -+ } -+ -+ private boolean isWhitelisted(String incomingClassName) { -+ for(int i = 0; i < javaPackages.length; i++) { -+ if(incomingClassName.startsWith(javaPackages[i])) -+ return true; -+ } -+ for(String className: whitelistedClassNames) { -+ if(incomingClassName.equals(className)) -+ return true; -+ } -+ return false; -+ } -+} diff -Nru logback-1.1.9/debian/patches/series logback-1.2.3/debian/patches/series --- logback-1.1.9/debian/patches/series 2017-11-27 02:59:24.000000000 +0000 +++ logback-1.2.3/debian/patches/series 2017-12-01 03:21:55.000000000 +0000 @@ -1,6 +1,2 @@ -01-compile-groovy.patch 02-remove-google-ads.patch -CVE-2017-5929.patch -CVE-2017-5929-part2.patch -03-servlet-3.1.patch 04-privacy-breach.patch diff -Nru logback-1.1.9/docs/access.html logback-1.2.3/docs/access.html --- logback-1.1.9/docs/access.html 2017-01-20 18:53:48.000000000 +0000 +++ logback-1.2.3/docs/access.html 2017-04-01 04:26:02.000000000 +0000 @@ -62,8 +62,8 @@

To use logback-access with Tomcat, after downloading the logback distribution, place the files - logback-core-1.1.9.jar and - logback-access-1.1.9.jar under + logback-core-1.2.3.jar and + logback-access-1.2.3.jar under $TOMCAT_HOME/lib/ directory, where $TOMCAT_HOME is the folder where you have installed Tomcat.

diff -Nru logback-1.1.9/docs/css/maven-base.css logback-1.2.3/docs/css/maven-base.css --- logback-1.1.9/docs/css/maven-base.css 2017-01-20 18:53:03.000000000 +0000 +++ logback-1.2.3/docs/css/maven-base.css 2017-04-01 03:21:16.000000000 +0000 @@ -1,155 +1,174 @@ -body { - margin: 0px; - padding: 0px; -} -img { - border:none; -} -table { - padding:0px; - width: 100%; - margin-left: -2px; - margin-right: -2px; -} -acronym { - cursor: help; - border-bottom: 1px dotted #feb; -} -table.bodyTable th, table.bodyTable td { - padding: 2px 4px 2px 4px; - vertical-align: top; -} -div.clear{ - clear:both; - visibility: hidden; -} -div.clear hr{ - display: none; -} -#bannerLeft, #bannerRight { - font-size: xx-large; - font-weight: bold; -} -#bannerLeft img, #bannerRight img { - margin: 0px; -} -.xleft, #bannerLeft img { - float:left; -} -.xright, #bannerRight { - float:right; -} -#banner { - padding: 0px; -} -#banner img { - border: none; -} -#breadcrumbs { - padding: 3px 10px 3px 10px; -} -#leftColumn { - width: 170px; - float:left; - overflow: auto; -} -#bodyColumn { - margin-right: 1.5em; - margin-left: 197px; -} -#legend { - padding: 8px 0 8px 0; -} -#navcolumn { - padding: 8px 4px 0 8px; -} -#navcolumn h5 { - margin: 0; - padding: 0; - font-size: small; -} -#navcolumn ul { - margin: 0; - padding: 0; - font-size: small; -} -#navcolumn li { - list-style-type: none; - background-image: none; - background-repeat: no-repeat; - background-position: 0 0.4em; - padding-left: 16px; - list-style-position: outside; - line-height: 1.2em; - font-size: smaller; -} -#navcolumn li.expanded { - background-image: url(../images/expanded.gif); -} -#navcolumn li.collapsed { - background-image: url(../images/collapsed.gif); -} -#navcolumn li.none { - text-indent: -1em; - margin-left: 1em; -} -#poweredBy { - text-align: center; -} -#navcolumn img { - margin-top: 10px; - margin-bottom: 3px; -} -#poweredBy img { - display:block; - margin: 20px 0 20px 17px; -} -#search img { - margin: 0px; - display: block; -} -#search #q, #search #btnG { - border: 1px solid #999; - margin-bottom:10px; -} -#search form { - margin: 0px; -} -#lastPublished { - font-size: x-small; -} -.navSection { - margin-bottom: 2px; - padding: 8px; -} -.navSectionHead { - font-weight: bold; - font-size: x-small; -} -.section { - padding: 4px; -} -#footer { - padding: 3px 10px 3px 10px; - font-size: x-small; -} -#breadcrumbs { - font-size: x-small; - margin: 0pt; -} -.source { - padding: 12px; - margin: 1em 7px 1em 7px; -} -.source pre { - margin: 0px; - padding: 0px; -} -#navcolumn img.imageLink, .imageLink { - padding-left: 0px; - padding-bottom: 0px; - padding-top: 0px; - padding-right: 2px; - border: 0px; - margin: 0px; -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +body { + margin: 0px; + padding: 0px; +} +img { + border:none; +} +table { + padding:0px; + width: 100%; + margin-left: -2px; + margin-right: -2px; +} +acronym { + cursor: help; + border-bottom: 1px dotted #feb; +} +table.bodyTable th, table.bodyTable td { + padding: 2px 4px 2px 4px; + vertical-align: top; +} +div.clear{ + clear:both; + visibility: hidden; +} +div.clear hr{ + display: none; +} +#bannerLeft, #bannerRight { + font-size: xx-large; + font-weight: bold; +} +#bannerLeft img, #bannerRight img { + margin: 0px; +} +.xleft, #bannerLeft img { + float:left; +} +.xright, #bannerRight { + float:right; +} +#banner { + padding: 0px; +} +#banner img { + border: none; +} +#breadcrumbs { + padding: 3px 10px 3px 10px; +} +#leftColumn { + width: 170px; + float:left; + overflow: auto; +} +#bodyColumn { + margin-right: 1.5em; + margin-left: 197px; +} +#legend { + padding: 8px 0 8px 0; +} +#navcolumn { + padding: 8px 4px 0 8px; +} +#navcolumn h5 { + margin: 0; + padding: 0; + font-size: small; +} +#navcolumn ul { + margin: 0; + padding: 0; + font-size: small; +} +#navcolumn li { + list-style-type: none; + background-image: none; + background-repeat: no-repeat; + background-position: 0 0.4em; + padding-left: 16px; + list-style-position: outside; + line-height: 1.2em; + font-size: smaller; +} +#navcolumn li.expanded { + background-image: url(../images/expanded.gif); +} +#navcolumn li.collapsed { + background-image: url(../images/collapsed.gif); +} +#navcolumn li.none { + text-indent: -1em; + margin-left: 1em; +} +#poweredBy { + text-align: center; +} +#navcolumn img { + margin-top: 10px; + margin-bottom: 3px; +} +#poweredBy img { + display:block; + margin: 20px 0 20px 17px; +} +#search img { + margin: 0px; + display: block; +} +#search #q, #search #btnG { + border: 1px solid #999; + margin-bottom:10px; +} +#search form { + margin: 0px; +} +#lastPublished { + font-size: x-small; +} +.navSection { + margin-bottom: 2px; + padding: 8px; +} +.navSectionHead { + font-weight: bold; + font-size: x-small; +} +.section { + padding: 4px; +} +#footer { + padding: 3px 10px 3px 10px; + font-size: x-small; +} +#breadcrumbs { + font-size: x-small; + margin: 0pt; +} +.source { + padding: 12px; + margin: 1em 7px 1em 7px; +} +.source pre { + margin: 0px; + padding: 0px; +} +#navcolumn img.imageLink, .imageLink { + padding-left: 0px; + padding-bottom: 0px; + padding-top: 0px; + padding-right: 2px; + border: 0px; + margin: 0px; +} diff -Nru logback-1.1.9/docs/css/maven-theme.css logback-1.2.3/docs/css/maven-theme.css --- logback-1.1.9/docs/css/maven-theme.css 2017-01-20 18:53:03.000000000 +0000 +++ logback-1.2.3/docs/css/maven-theme.css 2017-04-01 03:21:16.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + body { padding: 0px 0px 10px 0px; } @@ -64,7 +83,7 @@ h5 { padding: 4px 4px 4px 6px; color: #900; - font-size: normal; + font-size: medium; } p { line-height: 1.3em; @@ -79,6 +98,7 @@ margin: 10px 0 0 5px; border: 1px solid #999; background-color: #eee; + padding-bottom: 3px; /* IE-9 scrollbar-fix */ } #navcolumn h5 { font-size: smaller; diff -Nru logback-1.1.9/docs/css/print.css logback-1.2.3/docs/css/print.css --- logback-1.1.9/docs/css/print.css 2017-01-20 18:53:03.000000000 +0000 +++ logback-1.2.3/docs/css/print.css 2017-04-01 03:21:16.000000000 +0000 @@ -1,7 +1,26 @@ -#banner, #footer, #leftcol, #breadcrumbs, .docs #toc, .docs .courtesylinks, #leftColumn, #navColumn { - display: none !important; -} -#bodyColumn, body.docs div.docs { - margin: 0 !important; - border: none !important -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#banner, #footer, #leftcol, #breadcrumbs, .docs #toc, .docs .courtesylinks, #leftColumn, #navColumn { + display: none !important; +} +#bodyColumn, body.docs div.docs { + margin: 0 !important; + border: none !important +} diff -Nru logback-1.1.9/docs/dependencies.html logback-1.2.3/docs/dependencies.html --- logback-1.1.9/docs/dependencies.html 2017-01-20 18:53:48.000000000 +0000 +++ logback-1.2.3/docs/dependencies.html 2017-04-01 04:26:02.000000000 +0000 @@ -48,7 +48,7 @@ JaninoEventEvaluatorBase and derived classes @@ -192,7 +192,7 @@ ch.qos.logback.access.jetty.*
    -
  • Jetty version 7.5.1.v20110908 +
  • Jetty version 8.2.0.v20160908
@@ -202,7 +202,7 @@ ch.qos.logback.access.tomcat.* diff -Nru logback-1.1.9/docs/download.html logback-1.2.3/docs/download.html --- logback-1.1.9/docs/download.html 2017-01-20 18:53:48.000000000 +0000 +++ logback-1.2.3/docs/download.html 2017-04-01 04:26:02.000000000 +0000 @@ -51,8 +51,8 @@

diff -Nru logback-1.1.9/docs/faq.html logback-1.2.3/docs/faq.html --- logback-1.1.9/docs/faq.html 2017-01-20 18:53:48.000000000 +0000 +++ logback-1.2.3/docs/faq.html 2017-04-01 04:26:02.000000000 +0000 @@ -317,8 +317,8 @@

Logback jar files must be present on Jetty's class path. These files are - logback-core-1.1.9.jar and - logback-classic-1.1.9.jar. These files + logback-core-1.2.3.jar and + logback-classic-1.2.3.jar. These files should be placed under the $JETTY_HOME/lib directory.

@@ -326,7 +326,7 @@

Since Jetty uses an older version of SLF4J internally, we recommend that the old version be replaced by - slf4j-api-1.7.22.jar. This file can be + slf4j-api-1.7.25.jar. This file can be downloaded from the SLF4J project.

Binary files /tmp/tmp_w3zLB/z9ana35gcZ/logback-1.1.9/docs/images/setup/deselectMavenDependenciesExport.png and /tmp/tmp_w3zLB/lmaIvID0_A/logback-1.2.3/docs/images/setup/deselectMavenDependenciesExport.png differ Binary files /tmp/tmp_w3zLB/z9ana35gcZ/logback-1.1.9/docs/images/setup/discoverM2EConnectors.png and /tmp/tmp_w3zLB/lmaIvID0_A/logback-1.2.3/docs/images/setup/discoverM2EConnectors.png differ Binary files /tmp/tmp_w3zLB/z9ana35gcZ/logback-1.1.9/docs/images/setup/removeGroovyExclusions.png and /tmp/tmp_w3zLB/lmaIvID0_A/logback-1.2.3/docs/images/setup/removeGroovyExclusions.png differ diff -Nru logback-1.1.9/docs/js/dsl.js logback-1.2.3/docs/js/dsl.js --- logback-1.1.9/docs/js/dsl.js 2017-01-20 18:53:48.000000000 +0000 +++ logback-1.2.3/docs/js/dsl.js 2017-04-01 03:20:39.000000000 +0000 @@ -1,5 +1,5 @@ -var asGroovyURL='http://logback.qos.ch/translator/dsl/asGroovy'; +var asGroovyURL='https://logback.qos.ch/translator/dsl/asGroovy'; function asGroovy(id) { diff -Nru logback-1.1.9/docs/manual/appenders.html logback-1.2.3/docs/manual/appenders.html --- logback-1.1.9/docs/manual/appenders.html 2017-01-20 18:53:48.000000000 +0000 +++ logback-1.2.3/docs/manual/appenders.html 2017-04-01 04:26:02.000000000 +0000 @@ -272,7 +272,24 @@ underlying OutputStreamAppender. Encoders are described in a dedicated chapter. - + + + immediateFlush + boolean + + The default value for immediateFlush is 'true'. Immediate + flushing of the output stream ensures that logging events are + immediately written out and will not be lost in case your + application exits without properly closing appenders. On the + other hand, setting this property to 'false' is likely to + quadruple (your mileage may vary) logging throughput. Again, if + immediateFlush is set to 'false' and + if appenders are not closed properly when your application exits, + then logging events not yet written to disk may be lost. + + + @@ -435,7 +452,6 @@

- prudent @@ -509,11 +525,8 @@ events are not lost in case your application exits without properly closing appenders. However, for significantly increased logging throughput, you may want to set the immediateFlush property of the underlying - Encoder to false . Encoders and in - particular LayoutWrappingEncoder - are described in a separate chapter.

+ class="prop">immediateFlush property to + false.

Below is an example of a configuration file for FileAppender: @@ -528,6 +541,8 @@ <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>testFile.log</file> <append>true</append> + <!-- set immediateFlush to false for much higher logging throughput --> + <immediateFlush>true</immediateFlush> <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> <encoder> @@ -4532,8 +4547,8 @@ <defaultValue>NA</defaultValue> </Discriminator> <sift> - <appender name="ch.qos.logback:logback-site:jar:1.1.9" class="ch.qos.logback.core.FileAppender"> - <file>byUser/ch.qos.logback:logback-site:jar:1.1.9.log</file> + <appender name="ch.qos.logback:logback-site:jar:1.2.3" class="ch.qos.logback.core.FileAppender"> + <file>byUser/ch.qos.logback:logback-site:jar:1.2.3.log</file> <layout class="ch.qos.logback.access.PatternLayout"> <pattern>%h %l %u %t \"%r\" %s %b</pattern> </layout> diff -Nru logback-1.1.9/docs/manual/configuration.html logback-1.2.3/docs/manual/configuration.html --- logback-1.1.9/docs/manual/configuration.html 2017-01-20 18:53:48.000000000 +0000 +++ logback-1.2.3/docs/manual/configuration.html 2017-04-01 04:26:02.000000000 +0000 @@ -81,20 +81,21 @@

    +
  1. Logback tries to find a file called - logback.groovy logback-test.xml in the - classpath.

    -
  2. + classpath.

  3. -

    If no such file is found, logback tries to find a file - called logback-test.xml If no such file is found, logback tries to find a file called + logback.groovy in the classpath.

  4. +
  5. If no such file is found, it checks for the file logback.xml in the @@ -160,7 +161,7 @@ BasicConfigurator usage (logback-examples/src/main/java/chapters/configuration/MyApp1.java)

    -
    package manual.configuration;
    +    
    package chapters.configuration;
     
     import org.slf4j.Logger;
     import org.slf4j.LoggerFactory;
    @@ -778,8 +779,8 @@
        

    java -Dlogback.statusListenerClass=ch.qos.logback.core.status.NopStatusListener ...

    -

    Stopping - logback-classic

    +

    Stopping + logback-classic

    In order to release the resources used by logback-classic, it is always a good idea to stop the logback context. Stopping the @@ -800,7 +801,9 @@ the contextDestroyed method of ServletContextListener in order to stop - logback-classic and release resources. + logback-classic and release resources. Starting with version + 1.1.10, the appropriate ServletContextListener is + installed automatically for you (see just below).

    Stopping logback-classic @@ -823,8 +826,48 @@ can delay shutdown by a user specified duration. Note that you may install a shutdown hook of your own making by setting the class attribute to correspond to your shutdown - hook's class name.

    . + hook's class name.

    + +

    Stopping logback-classic + in web-applications

    + +

    since 1.1.10 Logback-classic will + automatically ask the web-server to install a LogbackServletContainerInitializer + implementing the ServletContainerInitializer interface + (available in servlet-api 3.x and later). This initializer will in + turn install and instance of LogbackServletContextListener. + This listener will stop the current logback-classic context when + the web-app is stopped or reloaded. +

    + +

    You may disable the automatic the installation of + LogbackServletContextListener by setting a + <context-param> named + logbackDisableServletContainerInitializer in your + web-application's web.xml file. Here is the relevant snippet.

    + + +
    <web-app>
    +    <context-param>
    +        <param-name>logbackDisableServletContainerInitializer</param-name>
    +        <param-value>true</param-value>
    +    </context-param>
    +    .... 
    +</web-app>
    + +

    Note that + logbackDisableServletContainerInitializer variable + can also be set as a Java system property an OS environment + variable. The most local setting has priority, i.e. web-app first, + system property second and OS environment last.

    + + + + +

    Configuration file syntax

    As you have seen thus far in the manual with plenty of examples @@ -1470,7 +1513,12 @@

    As they often come in handy, the HOSTNAME and CONTEXT_NAME - variables are automatically defined and have context scope.

    + variables are automatically defined and have context scope. Given + that in some environments it may take some time to compute the + hostname, its value is computed lazily (only when needed). Moreover, + HOSTNAME can be set from within the configuration directly. +

    Defining variables

    diff -Nru logback-1.1.9/docs/manual/encoders.html logback-1.2.3/docs/manual/encoders.html --- logback-1.1.9/docs/manual/encoders.html 2017-01-20 18:53:48.000000000 +0000 +++ logback-1.2.3/docs/manual/encoders.html 2017-04-01 04:26:02.000000000 +0000 @@ -142,13 +142,11 @@ protected Layout<E> layout; private Charset charset; - private boolean immediateFlush = true; - - public void doEncode(E event) throws IOException { - String txt = layout.doLayout(event); - outputStream.write(convertToBytes(txt)); - if (immediateFlush) - outputStream.flush(); + + // encode a given event as a byte[] + public byte[] encode(E event) { + String txt = layout.doLayout(event); + return convertToBytes(txt); } private byte[] convertToBytes(String s) { @@ -163,15 +161,7 @@

    The doEncode() method starts by having the wrapped layout convert the incoming event into string. The resulting text string is converted to bytes according to the charset encoding - chosen by the user. Those bytes are then written to the - OutputStream given by the owning appender. By - default, the OutputStream is immediately flushed, - unless the immediateFlush property is - explicitly set to 'false'. Setting the immediateFlush property to false can - significantly improve logging throughput. See - PatternLayoutEncoder below for sample configuration.. -

    + chosen by the user.

    PatternLayoutEncoder

    @@ -194,36 +184,9 @@

    immediateFlush property

    -

    As a sub-class of LayoutWrappingEncoder, - PatternLayoutEncoder admits the immediateFlush property. The default value - for immediateFlush is 'true'. Immediate - flushing of the output stream ensures that logging events are - immediately written to disk and will not be lost in case your - application exits without properly closing appenders. On the - other hand, setting this property to 'false' is likely to - quintuple (your mileage may vary) logging throughput. As - mentioned previously, if immediateFlush - is set to 'false' and if appenders are not closed properly when - your application exits, then logging events not yet written to - disk may be lost. -

    - -

    Below is a sample configuration for a - FileAppender containing a - PatternLayoutEncoder with its immediateFlush property set to 'false'.

    - -
    <appender name="FILE" class="ch.qos.logback.core.FileAppender"> 
    -  <file>foo.log</file>
    -  <encoder>
    -    <pattern>%d %-5level [%thread] %logger{0}: %msg%n</pattern>
    -    <!-- this quadruples logging throughput -->
    -    <immediateFlush>false</immediateFlush>
    -  </encoder> 
    -</appender>
    - +

    As of logback 1.2.0, the + immediateFlush property is part of the + enclosing Appender.

    Output pattern string as header

    diff -Nru logback-1.1.9/docs/manual/groovy_ja.html logback-1.2.3/docs/manual/groovy_ja.html --- logback-1.1.9/docs/manual/groovy_ja.html 2017-01-20 18:53:48.000000000 +0000 +++ logback-1.2.3/docs/manual/groovy_ja.html 2017-04-01 04:26:02.000000000 +0000 @@ -48,7 +48,7 @@

    基本的なルールを説明します。logback.groovyはGroovyのプログラムです。Groovy言語はJava言語のスーパーセットなので、Javaにできるあらゆる設定アクションと同じことをlogback.groovyで実行することができます。ですが、logbackをJavaの構文でプログラム的に設定するのはかなり厄介なので、logback専用の拡張構文を追加しました。logback専用の拡張構文はできるだけ少なくなるようにしましたし、実際のところほんのわずかしかありません。Groovyに慣れているとしても本章に目を通してもらって、logback.groovyを書くのは非常に簡単であることを理解してください。Groovyに不慣れな方であっても、logback.xmlを使い続けるよりlogback.groovyの記法のほうがずっとわかりやすいと思えるようになるはずです。

    -

    改めて整理します。logback.groovyは最小限のlogback専用の拡張がなされたGroovyプログラムです。logback.groovyの中では、クラスのimportや変数定義、変数評価、GString のMavenProject: ch.qos.logback:logback-site:1.1.9 @ C:\\home\\ceki\\logback\\logback-site\\pom.xml記法、if-else構文などのGroovyの機能は全て利用可能です。

    +

    改めて整理します。logback.groovyは最小限のlogback専用の拡張がなされたGroovyプログラムです。logback.groovyの中では、クラスのimportや変数定義、変数評価、GString のMavenProject: ch.qos.logback:logback-site:1.2.3 @ C:\\home\\ceki\\logback\\logback-site\\pom.xml記法、if-else構文などのGroovyの機能は全て利用可能です。

    自動import

    @@ -222,7 +222,7 @@

    内部DSL、すべてはGroovyの賜物だ!

    -

    logback.groovyは内部DSLです。つまり、内容自体が実行可能なGroovyスクリプトなのです。したがって、logback.groovyの中ではGroovy言語に備わっているクラスimport、GString、変数定義、GString文字列中のMavenProject: ch.qos.logback:logback-site:1.1.9 @ C:\\home\\ceki\\logback\\logback-site\\pom.xml記法の評価、if-else文などのあらゆる機能を利用することができるのです。以降の説明ではlogback.groovyにおける典型的なGroovy言語の使用例を紹介します。 +

    logback.groovyは内部DSLです。つまり、内容自体が実行可能なGroovyスクリプトなのです。したがって、logback.groovyの中ではGroovy言語に備わっているクラスimport、GString、変数定義、GString文字列中のMavenProject: ch.qos.logback:logback-site:1.2.3 @ C:\\home\\ceki\\logback\\logback-site\\pom.xml記法の評価、if-else文などのあらゆる機能を利用することができるのです。以降の説明ではlogback.groovyにおける典型的なGroovy言語の使用例を紹介します。

    diff -Nru logback-1.1.9/docs/manual/introduction.html logback-1.2.3/docs/manual/introduction.html --- logback-1.1.9/docs/manual/introduction.html 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/docs/manual/introduction.html 2017-04-01 04:26:02.000000000 +0000 @@ -71,7 +71,7 @@

    The logback-*.jar files are part of the logback - distribution whereas slf4j-api-1.7.22.jar ships + distribution whereas slf4j-api-1.7.25.jar ships with SLF4J, a separate project.

    diff -Nru logback-1.1.9/docs/manual/layouts.html logback-1.2.3/docs/manual/layouts.html --- logback-1.1.9/docs/manual/layouts.html 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/docs/manual/layouts.html 2017-04-01 04:26:02.000000000 +0000 @@ -819,7 +819,8 @@ full stack trace will be output.

    -

    The throwable conversion word can followed by one of + +

    The throwable conversion word can followed by one of the following options:

      @@ -870,6 +871,17 @@ negative answer. Evaluators are described further down in this document.

      + +

      If you do not specify %throwable or another + throwable-related conversion word in the conversion pattern, + PatternLayout will automatically add it as the + last conversion word, on account of the importance of stack + trace information. The $nopex conversion word can be + substituted for %throwable, if you do not wish stack trace + information to be displayed. See also the %nopex conversion + word. +

      + @@ -888,16 +900,6 @@

      Same as the %throwable conversion word above with the addition of class packaging information.

      -

      If you do not specify %xThrowable or another - throwable-related conversion word in the conversion pattern, - PatternLayout will automatically add it as the - last conversion word, on account of the importance of stack - trace information. The $nopex conversion word can be - substituted for %xThrowable, if you do not wish stack - trace information to be displayed. See also the %nopex - conversion word. -

      -

      At the end of each stack frame of the exception, a string consisting of the jar file containing the relevant class followed by the "Implementation-Version" as found in that @@ -934,15 +936,18 @@ by a tilde, it is possible that the correct packaging data is in reality [wombat.jar:1.7].

      - + +

      Please note that given its potential cost, computation of + packaging data + is disabled by default. When computation of + packaging data is enabled, PatternLayout will + automatically assume the %xThrowable suffix instead of + %throwable suffix at the end of the pattern string.

      +

      Feedback from users indicates that Netbeans chokes on packaging - information. If you are a Netbeans user, then you should - disable packaging information in stack traces by adding - "%ex" at the end of of your conversion pattern. For example, - "%d %logger - %m%n" should be rewritten as "%d %logger - - %m%n%ex" + information.

      diff -Nru logback-1.1.9/docs/manual/loggingSeparation.html logback-1.2.3/docs/manual/loggingSeparation.html --- logback-1.1.9/docs/manual/loggingSeparation.html 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/docs/manual/loggingSeparation.html 2017-04-01 04:26:02.000000000 +0000 @@ -223,9 +223,9 @@ ContextJNDISelector

      First, place the logback jars (that is - logback-classic-1.1.9.jar, - logback-core-1.1.9.jar and - slf4j-api-1.7.22.jar) in Tomcat's global (shared) class + logback-classic-1.2.3.jar, + logback-core-1.2.3.jar and + slf4j-api-1.7.25.jar) in Tomcat's global (shared) class folder. In Tomcat 6.x, this directory is $TOMCAT_HOME/lib/.

      diff -Nru logback-1.1.9/docs/manual/mdc.html logback-1.2.3/docs/manual/mdc.html --- logback-1.1.9/docs/manual/mdc.html 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/docs/manual/mdc.html 2017-04-01 04:26:02.000000000 +0000 @@ -89,18 +89,18 @@ lets the developer place information in a diagnostic context that can be subsequently retrieved by certain logback components. The MDC manages contextual information on - a per thread basis. A child thread automatically - inherits a copy of the mapped diagnostic context of its - parent. Typically, while starting to service a new client request, - the developer will insert pertinent contextual information, such - as the client id, client's IP address, request parameters - etc. into the MDC. Logback components, if - appropriately configured, will automatically include this - information in each log entry. + a per thread basis. Typically, while starting to service + a new client request, the developer will insert pertinent + contextual information, such as the client id, client's IP + address, request parameters etc. into the + MDC. Logback components, if appropriately configured, + will automatically include this information in each log entry.

      Please note that MDC as implemented by logback-classic assumes - that values are placed into the MDC with moderate frequency.

      + that values are placed into the MDC with moderate frequency. Also + note that a child thread does not automatically inherit a copy of + the mapped diagnostic context of its parent.

      The next application named diff -Nru logback-1.1.9/docs/manual/onJoran.html logback-1.2.3/docs/manual/onJoran.html --- logback-1.1.9/docs/manual/onJoran.html 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/docs/manual/onJoran.html 2017-04-01 04:26:02.000000000 +0000 @@ -67,7 +67,7 @@

      To install Joran, simply download logback and add - logback-core-1.1.9.jar to your + logback-core-1.2.3.jar to your classpath.

      Historical perspective

      diff -Nru logback-1.1.9/docs/news.html logback-1.2.3/docs/news.html --- logback-1.1.9/docs/news.html 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/docs/news.html 2017-04-01 04:26:02.000000000 +0000 @@ -30,11 +30,201 @@ the QOS.ch announce mailing list.

      + +
      -

      January 20th, 2017, Release of version 1.1.9

      +

      March 30th, 2017, Release of version 1.2.3

      + +

      Fix unintentional dependency on + OutputStreamAppender in + LayoutWrappingEncoder as reported in LOGBACK-1287. +

      + +

      Fix spurious System.out.println in AsyncAppender's + worker thread. This issue was reported in LOGBACK-1292 by + Nikolas Loutas with Thibault Meyer the relevant patch.

      + +

      ConsoleAppender exception when run under Java WebStart. This + problem was reported in LOGBACK-1282 by + Clas Forsberg.

      + +

      March 16th, 2017, Release of version 1.2.2

      + +

      AsyncAppender no longer drops events when the + current thread has its interrupt flag set. This issue was reported + in LOGBACK-1247 by + Jakob Bergendahl who also provided the relevant pull request. +

      + +

      Removed JMSQueueAppender and + JMSTopicAppender. These appenders were undocumented + and had no apparent users.

      + +

      Remove comment in logback-classic's + META-INF/services/javax.servlet.ServletContainerInitializer + file in order to keep Wildfly 8 happy. This issue was reported in + LOGBACK-1265 + by Andy Wilkinson. +

      + +

      FileSize.toString() now reports files sizes in GB + in addition to sizes in MB and KB and Bytes. This fixes issue LOGBACK-1278.

      + +
      + +

      March 1st, 2017, Release of version 1.1.11

      + +

      Fix thread-safety issue with PatternLayoutBase + reported in LOGBACK-1270 by + Artem Bilan. Note that the fix was already present in the 1.2.x + series and was back-ported to the 1.1.x series.

      + +
      + +

      February 9th, 2017, Release of version 1.2.1

      + +

      To ensure backward compatibility of configuration files, the + immediateFlush property set for a + LayoutWrappingEncoder is propagated to the enclosing + OutputStreamAppender. +

      + +
      + +

      February 8th, 2017, Release of version 1.2.0

      + +
      +

      Encoder interface has changed and is no longer + expected to handle an OutputStream.

      +
      + +

      Encoder interface has changed and is no longer + expected to handle an OutputStream. This + simplification allows finer-grain locking resulting in significantly + improved performance. +

      + +

      Release 1.2.0 fixes a rather severe + serialization vulnerability in SocketServer and + ServerSocketReceiver. Users running these components + should upgrade immediately.

      + + +

      This release fixes a rather severe serialization vulnerability + in SocketServer and + ServerSocketReceiver. Users running these components + should upgrade immediately. +

      + +

      In TimeBasedRollingPolicy, fixed issue with totalSizeCap of more than 2^31. This problem + was reported in 1231 by Simon + Teng. +

      + +

      Logback-classic now searches for the file + logback-test.xml first, logback.groovy second + and logback.xml third. In previous versions + logback.groovy was looked up first which was non-sensical + in presense of logback-test.xml. This fixes LOGBACK-1245 + reported by Joern Huxhorn. +

      + + +
      + +

      February 5th, 2017, Release of version 1.1.10

      + +

      Several changes to improve throughput (see spreadsheet) +

      + +
        +
      1. The ReentrantLock in + OutputStreamAppender is now "unfair". In previous + versions of logback, a fair lock was used. Fair locks are much + slower. Just as importanly, logback has no mandate to influence + thread scheduling. +
      2. + +
      3. FileAppender now offers the bufferSize option. Previously, a + fixed-size 8K buffer was used. Increasing the bufferSize, for example to 256K, + significantly reduces thread-contention. +
      4. + +
      5. Critical parts of the code now use + COWArrayList, a custom developed allocation-free + lock-free thread-safe implementation of the {@link List} + interface. It is optimized for cases where iterations over the + list vastly outnumber modifications on the list. It is based on + CopyOnWriteArrayList but allows allocation-free + iterations over the list. +
      6. + +
      7. In PatternLayoutBase the same + StringBuilder is used over and over to reduce + memory allocation. This is safe as long as the owning appender + guarantees serial access to its layout. In the next version of + logback, i.e. 1.2.x, the read-write lock will no longer protect + access to the layout and there will be no guarantee of + serial access. +
      8. +
      + +

      In web-applications, logback-classic will automatically + install a listener which will stop the logging context and + release resources when your web-app is reloaded. This enhancement + was requested LOGBACK-1170 by + Martin Wegner. +

      + +

      The AccessEvent.prepareForDeferredProcessing() + method was not idempotent. This caused subtle bugs under + Jetty. See LOGBACK-1189 + for details. Many thanks to Per Olesen, Evan Meagher, Nick Babcock + and Mark Elliot for hunting down this bug. +

      + +

      As it may be time consuming in certain environments, the + HOSTNAME property is now computed lazily. This optimization + requested in LOGBACK-1221 by + Eugene Petrenko. +

      + + +

      Joran now supports external XML entities. This feature was + requested in 1091 and the + relevant PR graciously provided by Jonas Neukomm. +

      + +
      + +

      January 20th, 2017, Release of version 1.1.9

      Logback's internal executor service had a thread pool size of 2 which could be used up rather quickly, e.g. configuration scanning diff -Nru logback-1.1.9/docs/project-reports.html logback-1.2.3/docs/project-reports.html --- logback-1.1.9/docs/project-reports.html 2017-01-20 18:52:50.000000000 +0000 +++ logback-1.2.3/docs/project-reports.html 2017-04-01 04:25:53.000000000 +0000 @@ -1,5 +1,5 @@ - + @@ -10,7 +10,6 @@ @import url("./css/site.css"); - @@ -24,15 +23,13 @@

    + --> +

    Optional dependencies

    SMTPAppender requires @@ -213,12 +217,12 @@ convenience.

    -
    <!-- The org.codehaus.janino:commons-compiler:2.7.8 dependency -->
    +   
    <!-- The org.codehaus.janino:commons-compiler:3.0.6 dependency -->
     <!-- will be automatically pulled in by Maven's transitivity rules -->
     <dependency>
       <groupId>org.codehaus.janino</groupId>
       <artifactId>janino</artifactId>
    -  <version>2.7.8</version>
    +  <version>3.0.6</version>
     </dependency>
    @@ -257,7 +261,7 @@ Root directory. The import should finish successfully in a few seconds.

    -

    Building with Eclipse

    +

    Building with Eclipse and "mvn eclipse:eclipse"

    Building logback under Eclipse is a little trickier. Here are instructions for building logback under Eclipse using the maven @@ -276,13 +280,7 @@

      -
    1. Install Eclipse
    2. - - - -
    3. Install the Groovy plugin for Eclipse. +
    4. Ensure that the Groovy plugin for Eclipse is installed.
      • @@ -297,9 +295,7 @@
      • In Eclipse, select Help → Intall new Software → Work with the update site you chose in the previous step and - then Select "Groovy-Eclipse Feature". Installation of other - plugins in particular "m2e Configurator for Groovy-Eclipse" - is not necessary + then Select "Groovy-Eclipse Feature".
    5. @@ -318,30 +314,7 @@
    6. In Eclipse, import the logback project: Import→ General→ Existing Projects into Workspace, select $LOGBACK_HOME folder for the import -
    7. - - - - +
    8. In Eclipse, clean all projects in Eclipse (Project → Clean) @@ -356,13 +329,90 @@

      The above listed procedure has been last tested by the author - using Eclipse Luna on February 25th, 2016.

      + using Eclipse Neon on March 17th, 2017.

      + +

      Building with Eclipse+m2eclipse

      + +

      Building with Eclipse and m2eclipse is a bit more complicated + due to the use of Groovy in logback-classic. +

      + +

      Here are the required steps:

      + + +
        +
      1. Ensure that the Groovy plugin for Eclipse is installed. See + above for instructions.
      2. + +
      3. In Eclipse, import the logback project: Import→ + Maven→ Existing Maven Projects, select + $LOGBACK_HOME folder for the import +
      4. + +
      5. Install any discovered m2e connections, + e.g. "maven-bundle-plugin". +

        + + Click to enlarge + +

        + +

        You may need to restart Eclipse.

        . + +
      6. + +
      7. In Eclipse, select logback-classic project and check that it + has "Groovy" nature. If not add it by right clicking on + logback-classic project → Groovy → Convert Groovy to + Project. +
      8. + +
      9. At this stage Eclipse may complain about + GafferConfigurator not being resolved. To fix these + errors, select logback-classic project properties, select "Java + Build Path" → Source → "logback-classic/src/main/groovy". + Select "Excluded" and then click on Remove. + +

        + + Click to enlarge + +

        + +
      10. + +
      11. +

        Project → Clean → Clean all projects.

        +
      12. + +
      13. To fix the errors in the logback-examples project, you need + to instruct logback-classic to not export its Maven dependencies. + Select logback-classic project properties, select "Java + Build Path" → Order and Export and deselect "Maven Dependencies". + +

        + + Click to enlarge + +

        +
      14. + +
      15. +

        Project → Clean → Clean all projects.

        +
      16. + + + +
      + + + -

      Call for volunteers Given that many - users prefer M2Eclipse for building projects under Eclipse IDE, we - are looking for volunteers to help work out the steps for building - logback with M2Eclipse. +

      Call for volunteers Given that + many users prefer M2Eclipse for building projects under Eclipse + IDE, we are looking for volunteers to help simplify the steps + required for building logback with M2Eclipse.

      diff -Nru logback-1.1.9/docs/templates/creative.js logback-1.2.3/docs/templates/creative.js --- logback-1.1.9/docs/templates/creative.js 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/docs/templates/creative.js 2017-04-01 03:20:40.000000000 +0000 @@ -5,14 +5,14 @@ document.write('

      '); document.write(' Authors: Ceki Gülcü, Sébastien Pennec, Carl Harris'); document.write('
      '); -document.write(' Copyright © 2000-2016, QOS.ch

      '); +document.write(' Copyright © 2000-2017, QOS.ch

      '); document.write(' '); document.write(' '); document.write(' '); document.write(' Creative Commons License'); +document.write(' src="https://creativecommons.org/images/public/somerights20.png" />'); document.write(' '); document.write(' '); document.write(' '); diff -Nru logback-1.1.9/docs/templates/footer.js logback-1.2.3/docs/templates/footer.js --- logback-1.1.9/docs/templates/footer.js 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/docs/templates/footer.js 2017-04-01 03:20:40.000000000 +0000 @@ -7,7 +7,7 @@ document.write(' '); document.write(' '); -document.write(' Follow @qos_ch'); +document.write(' Follow @qos_ch'); document.write(' '); document.write(' '); diff -Nru logback-1.1.9/docs/templates/header.js logback-1.2.3/docs/templates/header.js --- logback-1.1.9/docs/templates/header.js 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/docs/templates/header.js 2017-04-01 03:20:40.000000000 +0000 @@ -1,5 +1,5 @@ document.write(''); -document.write('') diff -Nru logback-1.1.9/docs/templates/left.js logback-1.2.3/docs/templates/left.js --- logback-1.1.9/docs/templates/left.js 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/docs/templates/left.js 2017-04-01 03:20:40.000000000 +0000 @@ -20,8 +20,8 @@ document.write(''); -document.write(''); document.write(''); @@ -30,7 +30,7 @@ document.write(''); diff -Nru logback-1.1.9/logback-access/pom.xml logback-1.2.3/logback-access/pom.xml --- logback-1.1.9/logback-access/pom.xml 2017-01-20 18:37:25.000000000 +0000 +++ logback-1.2.3/logback-access/pom.xml 2017-04-01 03:15:20.000000000 +0000 @@ -1,3 +1,4 @@ + @@ -7,7 +8,7 @@ ch.qos.logback logback-parent - 1.1.9 + 1.2.3 logback-access @@ -52,7 +53,7 @@ true - hsqldb + org.hsqldb hsqldb test diff -Nru logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java --- logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java 2016-02-25 21:15:49.000000000 +0000 +++ logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java 2017-03-30 02:48:09.000000000 +0000 @@ -13,15 +13,13 @@ */ package ch.qos.logback.access.joran.action; -import ch.qos.logback.core.status.OnConsoleStatusListener; -import ch.qos.logback.core.util.OptionHelper; -import ch.qos.logback.core.util.StatusListenerConfigHelper; - import org.xml.sax.Attributes; import ch.qos.logback.core.joran.action.Action; import ch.qos.logback.core.joran.spi.InterpretationContext; -import ch.qos.logback.core.util.ContextUtil; +import ch.qos.logback.core.status.OnConsoleStatusListener; +import ch.qos.logback.core.util.OptionHelper; +import ch.qos.logback.core.util.StatusListenerConfigHelper; public class ConfigurationAction extends Action { static final String INTERNAL_DEBUG_ATTR = "debug"; @@ -44,8 +42,6 @@ StatusListenerConfigHelper.addOnConsoleListenerInstance(context, new OnConsoleStatusListener()); } - new ContextUtil(context).addHostNameAsProperty(); - // the context is appender attachable, so it is pushed on top of the stack ec.pushObject(getContext()); } diff -Nru logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java --- logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java 2016-02-25 21:15:49.000000000 +0000 +++ logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java 2017-03-30 02:48:09.000000000 +0000 @@ -19,6 +19,7 @@ import ch.qos.logback.access.joran.action.ConfigurationAction; import ch.qos.logback.access.joran.action.EvaluatorAction; import ch.qos.logback.access.sift.SiftAction; +import ch.qos.logback.access.spi.IAccessEvent; import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.UnsynchronizedAppenderBase; import ch.qos.logback.core.filter.EvaluatorFilter; @@ -39,14 +40,14 @@ * * @author Ceki Gülcü */ -public class JoranConfigurator extends JoranConfiguratorBase { +public class JoranConfigurator extends JoranConfiguratorBase { @Override public void addInstanceRules(RuleStore rs) { super.addInstanceRules(rs); rs.addRule(new ElementSelector("configuration"), new ConfigurationAction()); - rs.addRule(new ElementSelector("configuration/appender-ref"), new AppenderRefAction()); + rs.addRule(new ElementSelector("configuration/appender-ref"), new AppenderRefAction()); rs.addRule(new ElementSelector("configuration/appender/sift"), new SiftAction()); rs.addRule(new ElementSelector("configuration/appender/sift/*"), new NOPAction()); diff -Nru logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/net/HardenedAccessEventInputStream.java logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/net/HardenedAccessEventInputStream.java --- logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/net/HardenedAccessEventInputStream.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/net/HardenedAccessEventInputStream.java 2017-03-30 02:48:09.000000000 +0000 @@ -0,0 +1,15 @@ +package ch.qos.logback.access.net; + +import java.io.IOException; +import java.io.InputStream; + +import ch.qos.logback.access.spi.AccessEvent; +import ch.qos.logback.core.net.HardenedObjectInputStream; + +public class HardenedAccessEventInputStream extends HardenedObjectInputStream { + + public HardenedAccessEventInputStream(InputStream in) throws IOException { + super(in, new String[] {AccessEvent.class.getName(), String[].class.getName()}); + } + +} diff -Nru logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java --- logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java 2016-02-25 21:15:49.000000000 +0000 +++ logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/net/SocketNode.java 2017-03-30 02:48:09.000000000 +0000 @@ -15,7 +15,6 @@ import java.io.BufferedInputStream; import java.io.IOException; -import java.io.ObjectInputStream; import java.net.Socket; import ch.qos.logback.access.spi.AccessContext; @@ -42,18 +41,18 @@ Socket socket; AccessContext context; - ObjectInputStream ois; + HardenedAccessEventInputStream hardenedOIS; public SocketNode(Socket socket, AccessContext context) { this.socket = socket; this.context = context; try { - ois = new ObjectInputStream(new BufferedInputStream(socket.getInputStream())); + hardenedOIS = new HardenedAccessEventInputStream(new BufferedInputStream(socket.getInputStream())); } catch (Exception e) { - System.out.println("Could not open ObjectInputStream to " + socket + e); + System.out.println("Could not open HardenedObjectInputStream to " + socket + e); } } - + @Override public void run() { IAccessEvent event; @@ -61,7 +60,7 @@ try { while (true) { // read an event from the wire - event = (IAccessEvent) ois.readObject(); + event = (IAccessEvent) hardenedOIS.readObject(); // check that the event should be logged if (context.getFilterChainDecision(event) == FilterReply.DENY) { break; @@ -81,7 +80,7 @@ } try { - ois.close(); + hardenedOIS.close(); } catch (Exception e) { System.out.println("Could not close connection." + e); } diff -Nru logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java --- logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java 2016-02-25 21:15:50.000000000 +0000 +++ logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletInputStream.java 2017-03-30 02:48:10.000000000 +0000 @@ -18,6 +18,7 @@ import java.io.IOException; import java.io.InputStream; +import javax.servlet.ReadListener; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; @@ -30,11 +31,6 @@ duplicateInputStream(request); } - @Override - public int read() throws IOException { - return in.read(); - } - private void duplicateInputStream(HttpServletRequest request) { ServletInputStream originalSIS = null; try { @@ -44,10 +40,15 @@ } catch (IOException e) { e.printStackTrace(); } finally { - closeStrean(originalSIS); + closeStream(originalSIS); } } + @Override + public int read() throws IOException { + return in.read(); + } + byte[] consumeBufferAndReturnAsByteArray(InputStream is) throws IOException { int len = 1024; byte[] temp = new byte[len]; @@ -59,7 +60,7 @@ return baos.toByteArray(); } - void closeStrean(ServletInputStream is) { + void closeStream(ServletInputStream is) { if (is != null) { try { is.close(); @@ -71,4 +72,19 @@ byte[] getInputBuffer() { return inputBuffer; } + + @Override + public boolean isFinished() { + throw new RuntimeException("Not yet implemented"); + } + + @Override + public boolean isReady() { + throw new RuntimeException("Not yet implemented"); + } + + @Override + public void setReadListener(ReadListener listener) { + throw new RuntimeException("Not yet implemented"); + } } diff -Nru logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java --- logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java 2016-02-25 21:15:50.000000000 +0000 +++ logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/servlet/TeeServletOutputStream.java 2017-03-30 02:48:10.000000000 +0000 @@ -18,6 +18,7 @@ import javax.servlet.ServletOutputStream; import javax.servlet.ServletResponse; +import javax.servlet.WriteListener; public class TeeServletOutputStream extends ServletOutputStream { @@ -33,7 +34,7 @@ byte[] getOutputStreamAsByteArray() { return baosCopy.toByteArray(); } - + @Override public void write(int val) throws IOException { if (underlyingStream != null) { @@ -82,4 +83,14 @@ underlyingStream.flush(); baosCopy.flush(); } + + @Override + public boolean isReady() { + throw new RuntimeException("Not yet implemented"); + } + + @Override + public void setWriteListener(WriteListener listener) { + throw new RuntimeException("Not yet implemented"); + } } diff -Nru logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java --- logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java 2016-02-29 21:56:20.000000000 +0000 +++ logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/spi/AccessEvent.java 2017-03-30 02:48:10.000000000 +0000 @@ -44,6 +44,8 @@ */ public class AccessEvent implements Serializable, IAccessEvent { + private static final String[] NA_STRING_ARRAY = new String[] { NA }; + private static final long serialVersionUID = 866718993618836343L; private static final String EMPTY = ""; @@ -371,6 +373,11 @@ return; } + // attributeMap has been copied already. See also LOGBACK-1189 + if(attributeMap != null) { + return; + } + attributeMap = new HashMap(); Enumeration names = httpRequest.getAttributeNames(); @@ -400,16 +407,15 @@ @Override public String[] getRequestParameter(String key) { - if (httpRequest != null) { - String[] value = httpRequest.getParameterValues(key); - if (value == null) { - return new String[] { NA }; - } else { - return value; - } - } else { - return new String[] { NA }; + String[] value = null; + + if(requestParameterMap != null) { + value = requestParameterMap.get(key); + } else if (httpRequest != null) { + value = httpRequest.getParameterValues(key); } + + return (value != null) ? value: NA_STRING_ARRAY; } @Override diff -Nru logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/spi/IAccessEvent.java logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/spi/IAccessEvent.java --- logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/spi/IAccessEvent.java 2016-02-29 21:56:26.000000000 +0000 +++ logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/spi/IAccessEvent.java 2017-03-30 02:48:10.000000000 +0000 @@ -98,7 +98,7 @@ String getRequestHeader(String key); - Enumeration getRequestHeaderNames(); + Enumeration getRequestHeaderNames(); Map getRequestHeaderMap(); diff -Nru logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java --- logback-1.1.9/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java 2016-12-12 12:17:38.000000000 +0000 +++ logback-1.2.3/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java 2017-03-30 02:48:10.000000000 +0000 @@ -328,7 +328,6 @@ return aai.detachAppender(name); } - @Override public String getInfo() { return "Logback's implementation of ValveBase"; } diff -Nru logback-1.1.9/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java logback-1.2.3/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java --- logback-1.1.9/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java 2016-02-25 21:15:49.000000000 +0000 +++ logback-1.2.3/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyRequest.java 2017-03-30 02:48:10.000000000 +0000 @@ -33,7 +33,9 @@ public static final String DUMMY_RESPONSE_CONTENT_STRING = "response contents"; public static final byte[] DUMMY_RESPONSE_CONTENT_BYTES = DUMMY_RESPONSE_CONTENT_STRING.getBytes(); - Hashtable headerNames; + Hashtable headerMap; + Hashtable parameterMap; + String uri; Map attributes; @@ -44,10 +46,13 @@ } public DummyRequest() { - headerNames = new Hashtable(); - headerNames.put("headerName1", "headerValue1"); - headerNames.put("headerName2", "headerValue2"); - + headerMap = new Hashtable(); + headerMap.put("headerName1", "headerValue1"); + headerMap.put("headerName2", "headerValue2"); + + parameterMap = new Hashtable(); + parameterMap.put("param1", new String[] {"value1"}); + attributes = new HashMap(DUMMY_DEFAULT_ATTR_MAP); } @@ -69,17 +74,25 @@ } public String getHeader(String key) { - return headerNames.get(key); + return headerMap.get(key); } - public Enumeration getHeaderNames() { - return headerNames.keys(); + + @Override + public Enumeration getHeaderNames() { + return headerMap.keys(); } - public Enumeration getHeaders(String arg0) { + @Override + public Enumeration getHeaders(String arg) { return null; } + public Map getHeaders() { + return headerMap; + } + + public int getIntHeader(String arg0) { return 0; } @@ -176,7 +189,7 @@ return attributes.get(key); } - public Enumeration getAttributeNames() { + public Enumeration getAttributeNames() { return Collections.enumeration(attributes.keySet()); } @@ -240,24 +253,31 @@ return null; } - public Enumeration getLocales() { + @Override + public Enumeration getLocales() { return null; } - public String getParameter(String arg0) { - return null; + public String getParameter(String arg) { + String[] stringArray = parameterMap.get(arg); + if(stringArray == null || stringArray.length == 0) + return null; + else + return stringArray[0]; } - public Map getParameterMap() { - return null; + @Override + public Map getParameterMap() { + return parameterMap; } - public Enumeration getParameterNames() { - return null; + public Enumeration getParameterNames() { + return parameterMap.keys(); + //eturn Collections.enumeration(parameterMap.keySet()); } - public String[] getParameterValues(String arg0) { - return null; + public String[] getParameterValues(String arg) { + return parameterMap.get(arg); } public String getProtocol() { @@ -317,4 +337,20 @@ public void setRequestUri(String uri) { this.uri = uri; } + + @Override + public long getContentLengthLong() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String changeSessionId() { + return null; + } + + @Override + public T upgrade(Class httpUpgradeHandlerClass) throws IOException, ServletException { + return null; + } } diff -Nru logback-1.1.9/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java logback-1.2.3/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java --- logback-1.1.9/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java 2016-02-25 21:15:49.000000000 +0000 +++ logback-1.2.3/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyResponse.java 2017-03-30 02:48:10.000000000 +0000 @@ -158,7 +158,7 @@ public Collection getHeaders(String name) { String val = headerMap.get(name); - List list = new ArrayList(); + List list = new ArrayList(); if (val != null) list.add(val); return list; @@ -180,4 +180,9 @@ this.status = status; } + @Override + public void setContentLengthLong(long length) { + // TODO Auto-generated method stub + } + } diff -Nru logback-1.1.9/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServletOutputStream.java logback-1.2.3/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServletOutputStream.java --- logback-1.1.9/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServletOutputStream.java 2016-02-25 21:15:49.000000000 +0000 +++ logback-1.2.3/logback-access/src/test/java/ch/qos/logback/access/dummy/DummyServletOutputStream.java 2017-03-30 02:48:10.000000000 +0000 @@ -14,6 +14,8 @@ package ch.qos.logback.access.dummy; import javax.servlet.ServletOutputStream; +import javax.servlet.WriteListener; + import java.io.IOException; import java.io.OutputStream; @@ -39,4 +41,16 @@ super.close(); this.targetStream.close(); } + + @Override + public boolean isReady() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void setWriteListener(WriteListener listener) { + // TODO Auto-generated method stub + + } } diff -Nru logback-1.1.9/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventSerializationTest.java logback-1.2.3/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventSerializationTest.java --- logback-1.1.9/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventSerializationTest.java 2016-02-25 21:15:49.000000000 +0000 +++ logback-1.2.3/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventSerializationTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -13,16 +13,21 @@ */ package ch.qos.logback.access.spi; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +import org.junit.Test; + import ch.qos.logback.access.dummy.DummyAccessEventBuilder; import ch.qos.logback.access.dummy.DummyRequest; import ch.qos.logback.access.dummy.DummyResponse; import ch.qos.logback.access.dummy.DummyServerAdapter; -import org.junit.Test; - -import java.io.*; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import ch.qos.logback.access.net.HardenedAccessEventInputStream; public class AccessEventSerializationTest { @@ -36,9 +41,11 @@ oos.flush(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream ois = new ObjectInputStream(bais); + HardenedAccessEventInputStream hardenedOIS = new HardenedAccessEventInputStream(bais); - return ois.readObject(); + Object sae = hardenedOIS.readObject(); + hardenedOIS.close(); + return sae; } @Test diff -Nru logback-1.1.9/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventTest.java logback-1.2.3/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventTest.java --- logback-1.1.9/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventTest.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-access/src/test/java/ch/qos/logback/access/spi/AccessEventTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,57 @@ +package ch.qos.logback.access.spi; + +import static org.junit.Assert.*; + +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import ch.qos.logback.access.dummy.DummyAccessEventBuilder; +import ch.qos.logback.access.dummy.DummyRequest; +import ch.qos.logback.core.testUtil.RandomUtil; + +public class AccessEventTest { + + int diff = RandomUtil.getPositiveInt(); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + // See LOGBACK-1189 + @Test + public void callingPrepareForDeferredProcessingShouldBeIdempotent() { + String key = "key-"+diff; + String val = "val-"+diff; + + IAccessEvent ae = DummyAccessEventBuilder.buildNewAccessEvent(); + DummyRequest request = (DummyRequest) ae.getRequest(); + Map headersMap = request.getHeaders(); + Map parametersMap = request.getParameterMap(); + + headersMap.put(key, val); + request.setAttribute(key, val); + parametersMap.put(key, new String[] {val}); + ae.prepareForDeferredProcessing(); + assertEquals(val, ae.getAttribute(key)); + assertEquals(val, ae.getRequestHeader(key)); + assertEquals(val, ae.getRequestParameter(key)[0]); + + + request.setAttribute(key, "change"); + headersMap.put(key, "change"); + parametersMap.put(key, new String[] {"change"}); + ae.prepareForDeferredProcessing(); + assertEquals(val, ae.getAttribute(key)); + assertEquals(val, ae.getRequestHeader(key)); + assertEquals(val, ae.getRequestParameter(key)[0]); + + } + +} diff -Nru logback-1.1.9/logback-classic/integration.xml logback-1.2.3/logback-classic/integration.xml --- logback-1.1.9/logback-classic/integration.xml 2013-03-15 14:06:04.000000000 +0000 +++ logback-1.2.3/logback-classic/integration.xml 2017-03-30 02:48:10.000000000 +0000 @@ -1,3 +1,4 @@ + - - org.codehaus.groovy - groovy-eclipse-batch - 2.3.7-01 - - - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.8 - - - org.eclipse.jdt.groovy.core.groovyNature - - - - **/*.groovy - - - true - true - + org.codehaus.gmavenplus + gmavenplus-plugin + 1.5 + + + + generateStubs + compile + testGenerateStubs + testCompile + + + @@ -235,7 +221,7 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 + 1.8 org.apache.ant @@ -307,7 +293,6 @@ org.apache.felix maven-bundle-plugin - 2.5.3 true @@ -346,6 +331,34 @@ + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.gmavenplus + gmavenplus-plugin + [1.5,) + + testGenerateStubs + generateStubs + testCompile + compile + + + + + + + + + + diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java 2016-03-11 12:55:56.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java 2017-03-30 02:48:10.000000000 +0000 @@ -61,14 +61,12 @@ processScanAttrib(ic, attributes); - ContextUtil contextUtil = new ContextUtil(context); - contextUtil.addHostNameAsProperty(); - LoggerContext lc = (LoggerContext) context; boolean packagingData = OptionHelper.toBoolean(ic.subst(attributes.getValue(PACKAGING_DATA_ATTR)), LoggerContext.DEFAULT_PACKAGING_DATA); lc.setPackagingDataEnabled(packagingData); if (EnvUtil.isGroovyAvailable()) { + ContextUtil contextUtil = new ContextUtil(context); contextUtil.addGroovyPackages(lc.getFrameworkPackages()); } diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueAppender.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueAppender.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueAppender.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueAppender.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,206 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net; - -import java.io.Serializable; - -import javax.jms.ObjectMessage; -import javax.jms.Queue; -import javax.jms.QueueConnection; -import javax.jms.QueueConnectionFactory; -import javax.jms.QueueSender; -import javax.jms.QueueSession; -import javax.jms.Session; -import javax.naming.Context; - -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.AppenderBase; -import ch.qos.logback.core.net.JMSAppenderBase; -import ch.qos.logback.core.spi.PreSerializationTransformer; - -/** - * A simple appender that publishes events to a JMS Queue. The events are - * serialized and transmitted as JMS message type {@link - * javax.jms.ObjectMessage}. - *

      - * For more information about this appender, please refer to: - * http://logback.qos.ch/manual/appenders.html#JMSQueueAppender - * - * @author Ceki Gülcü - */ -public class JMSQueueAppender extends JMSAppenderBase { - - static int SUCCESSIVE_FAILURE_LIMIT = 3; - - String queueBindingName; - String qcfBindingName; - QueueConnection queueConnection; - QueueSession queueSession; - QueueSender queueSender; - - int successiveFailureCount = 0; - - private PreSerializationTransformer pst = new LoggingEventPreSerializationTransformer(); - - /** - * The QueueConnectionFactoryBindingName option takes a string value. - * Its value will be used to lookup the appropriate - * QueueConnectionFactory from the JNDI context. - */ - public void setQueueConnectionFactoryBindingName(String qcfBindingName) { - this.qcfBindingName = qcfBindingName; - } - - /** - * Returns the value of the QueueConnectionFactoryBindingName option. - */ - public String getQueueConnectionFactoryBindingName() { - return qcfBindingName; - } - - /** - * The QueueBindingName option takes a string value. Its value will be - * used to lookup the appropriate Queue from the JNDI context. - */ - public void setQueueBindingName(String queueBindingName) { - this.queueBindingName = queueBindingName; - } - - /** - * Returns the value of the QueueBindingName option. - */ - public String getQueueBindingName() { - return queueBindingName; - } - - /** - * Options are activated and become effective only after calling this method. - */ - public void start() { - QueueConnectionFactory queueConnectionFactory; - - try { - Context jndi = buildJNDIContext(); - - // addInfo("Looking up [" + qcfBindingName + "]"); - queueConnectionFactory = (QueueConnectionFactory) lookup(jndi, qcfBindingName); - // addInfo("About to create QueueConnection."); - if (userName != null) { - this.queueConnection = queueConnectionFactory.createQueueConnection(userName, password); - } else { - this.queueConnection = queueConnectionFactory.createQueueConnection(); - } - - // addInfo( - // "Creating QueueSession, non-transactional, " - // + "in AUTO_ACKNOWLEDGE mode."); - this.queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); - - // addInfo("Looking up queue name [" + queueBindingName + "]."); - Queue queue = (Queue) lookup(jndi, queueBindingName); - - // addInfo("Creating QueueSender."); - this.queueSender = queueSession.createSender(queue); - - // addInfo("Starting QueueConnection."); - queueConnection.start(); - - jndi.close(); - } catch (Exception e) { - addError("Error while activating options for appender named [" + name + "].", e); - } - - if (this.queueConnection != null && this.queueSession != null && this.queueSender != null) { - super.start(); - } - } - - /** - * Close this JMSAppender. Closing releases all resources used by the - * appender. A closed appender cannot be re-opened. - */ - public synchronized void stop() { - // The synchronized modifier avoids concurrent append and close operations - if (!this.started) { - return; - } - - this.started = false; - - try { - if (queueSession != null) { - queueSession.close(); - } - if (queueConnection != null) { - queueConnection.close(); - } - } catch (Exception e) { - addError("Error while closing JMSAppender [" + name + "].", e); - } - - // Help garbage collection - queueSender = null; - queueSession = null; - queueConnection = null; - } - - /** - * This method called by {@link AppenderBase#doAppend} method to do most - * of the real appending work. - */ - public void append(ILoggingEvent event) { - if (!isStarted()) { - return; - } - - try { - ObjectMessage msg = queueSession.createObjectMessage(); - Serializable so = pst.transform(event); - msg.setObject(so); - queueSender.send(msg); - successiveFailureCount = 0; - } catch (Exception e) { - successiveFailureCount++; - if (successiveFailureCount > SUCCESSIVE_FAILURE_LIMIT) { - stop(); - } - addError("Could not send message in JMSQueueAppender [" + name + "].", e); - - } - } - - /** - * Returns the QueueConnection used for this appender. Only valid after - * start() method has been invoked. - */ - protected QueueConnection getQueueConnection() { - return queueConnection; - } - - /** - * Returns the QueueSession used for this appender. Only valid after start() - * method has been invoked. - */ - protected QueueSession getQueueSession() { - return queueSession; - } - - /** - * Returns the QueueSender used for this appender. Only valid after start() - * method has been invoked. - */ - protected QueueSender getQueueSender() { - return queueSender; - } -} diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSQueueSink.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.Properties; - -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.ObjectMessage; -import javax.jms.Queue; -import javax.jms.QueueConnection; -import javax.jms.QueueConnectionFactory; -import javax.jms.QueueSession; -import javax.jms.Session; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NameNotFoundException; -import javax.naming.NamingException; - -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.classic.util.ContextInitializer; - -/** - * A simple application that consumes logging events sent by a {@link - * JMSQueueAppender}. - * - * @author Ceki Gülcü - */ -public class JMSQueueSink implements javax.jms.MessageListener { - - private Logger logger = (Logger) LoggerFactory.getLogger(JMSTopicSink.class); - - static public void main(String[] args) throws Exception { - if (args.length < 2) { - usage("Wrong number of arguments."); - } - - String qcfBindingName = args[0]; - String queueBindingName = args[1]; - String username = null; - String password = null; - if (args.length == 4) { - username = args[2]; - password = args[3]; - } - - LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); - new ContextInitializer(loggerContext).autoConfig(); - - new JMSQueueSink(qcfBindingName, queueBindingName, username, password); - - BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); - // Loop until the word "exit" is typed - System.out.println("Type \"exit\" to quit JMSQueueSink."); - while (true) { - String s = stdin.readLine(); - if (s.equalsIgnoreCase("exit")) { - System.out.println("Exiting. Kill the application if it does not exit " + "due to daemon threads."); - return; - } - } - } - - public JMSQueueSink(String qcfBindingName, String queueBindingName, String username, String password) { - - try { - Properties env = new Properties(); - env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); - env.put(Context.PROVIDER_URL, "tcp://localhost:61616"); - Context ctx = new InitialContext(env); - QueueConnectionFactory queueConnectionFactory; - queueConnectionFactory = (QueueConnectionFactory) lookup(ctx, qcfBindingName); - System.out.println("Queue Cnx Factory found"); - Queue queue = (Queue) ctx.lookup(queueBindingName); - System.out.println("Queue found: " + queue.getQueueName()); - - QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(username, password); - System.out.println("Queue Connection created"); - - QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); - - MessageConsumer queueConsumer = queueSession.createConsumer(queue); - - queueConsumer.setMessageListener(this); - - queueConnection.start(); - System.out.println("Queue Connection started"); - - } catch (Exception e) { - logger.error("Could not read JMS message.", e); - } - } - - public void onMessage(javax.jms.Message message) { - ILoggingEvent event; - try { - if (message instanceof ObjectMessage) { - ObjectMessage objectMessage = (ObjectMessage) message; - event = (ILoggingEvent) objectMessage.getObject(); - Logger log = (Logger) LoggerFactory.getLogger(event.getLoggerName()); - log.callAppenders(event); - } else { - logger.warn("Received message is of type " + message.getJMSType() + ", was expecting ObjectMessage."); - } - } catch (JMSException jmse) { - logger.error("Exception thrown while processing incoming message.", jmse); - } - } - - protected Object lookup(Context ctx, String name) throws NamingException { - try { - return ctx.lookup(name); - } catch (NameNotFoundException e) { - logger.error("Could not find name [" + name + "]."); - throw e; - } - } - - static void usage(String msg) { - System.err.println(msg); - System.err.println("Usage: java " + JMSQueueSink.class.getName() + " QueueConnectionFactoryBindingName QueueBindingName Username Password"); - System.exit(1); - } -} diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicAppender.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicAppender.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicAppender.java 2016-02-25 21:15:37.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicAppender.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,205 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net; - -import java.io.Serializable; - -import javax.jms.ObjectMessage; -import javax.jms.Session; -import javax.jms.Topic; -import javax.jms.TopicConnection; -import javax.jms.TopicConnectionFactory; -import javax.jms.TopicPublisher; -import javax.jms.TopicSession; -import javax.naming.Context; - -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.AppenderBase; -import ch.qos.logback.core.net.JMSAppenderBase; -import ch.qos.logback.core.spi.PreSerializationTransformer; - -/** - * A simple appender that publishes events to a JMS Topic. The events are - * serialized and transmitted as JMS message type {@link - * javax.jms.ObjectMessage}. - * - * For more information about this appender, please refer to - * http://logback.qos.ch/manual/appenders.html#JMSTopicAppender - * - * @author Ceki Gülcü - */ -public class JMSTopicAppender extends JMSAppenderBase { - - static int SUCCESSIVE_FAILURE_LIMIT = 3; - - String topicBindingName; - String tcfBindingName; - TopicConnection topicConnection; - TopicSession topicSession; - TopicPublisher topicPublisher; - - int successiveFailureCount = 0; - - private PreSerializationTransformer pst = new LoggingEventPreSerializationTransformer(); - - /** - * The TopicConnectionFactoryBindingName option takes a string value. - * Its value will be used to lookup the appropriate - * TopicConnectionFactory from the JNDI context. - */ - public void setTopicConnectionFactoryBindingName(String tcfBindingName) { - this.tcfBindingName = tcfBindingName; - } - - /** - * Returns the value of the TopicConnectionFactoryBindingName option. - */ - public String getTopicConnectionFactoryBindingName() { - return tcfBindingName; - } - - /** - * The TopicBindingName option takes a string value. Its value will be - * used to lookup the appropriate Topic from the JNDI context. - */ - public void setTopicBindingName(String topicBindingName) { - this.topicBindingName = topicBindingName; - } - - /** - * Returns the value of the TopicBindingName option. - */ - public String getTopicBindingName() { - return topicBindingName; - } - - /** - * Options are activated and become effective only after calling this method. - */ - public void start() { - TopicConnectionFactory topicConnectionFactory; - - try { - Context jndi = buildJNDIContext(); - - // addInfo("Looking up [" + tcfBindingName + "]"); - topicConnectionFactory = (TopicConnectionFactory) lookup(jndi, tcfBindingName); - // addInfo("About to create TopicConnection."); - if (userName != null) { - this.topicConnection = topicConnectionFactory.createTopicConnection(userName, password); - } else { - this.topicConnection = topicConnectionFactory.createTopicConnection(); - } - - // addInfo( - // "Creating TopicSession, non-transactional, " - // + "in AUTO_ACKNOWLEDGE mode."); - this.topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); - - // addInfo("Looking up topic name [" + topicBindingName + "]."); - Topic topic = (Topic) lookup(jndi, topicBindingName); - - // addInfo("Creating TopicPublisher."); - this.topicPublisher = topicSession.createPublisher(topic); - - // addInfo("Starting TopicConnection."); - topicConnection.start(); - - jndi.close(); - } catch (Exception e) { - addError("Error while activating options for appender named [" + name + "].", e); - } - - if (this.topicConnection != null && this.topicSession != null && this.topicPublisher != null) { - super.start(); - } - } - - /** - * Close this JMSAppender. Closing releases all resources used by the - * appender. A closed appender cannot be re-opened. - */ - public synchronized void stop() { - // The synchronized modifier avoids concurrent append and close operations - if (!this.started) { - return; - } - - this.started = false; - - try { - if (topicSession != null) { - topicSession.close(); - } - if (topicConnection != null) { - topicConnection.close(); - } - } catch (Exception e) { - addError("Error while closing JMSAppender [" + name + "].", e); - } - - // Help garbage collection - topicPublisher = null; - topicSession = null; - topicConnection = null; - } - - /** - * This method called by {@link AppenderBase#doAppend} method to do most - * of the real appending work. - */ - public void append(ILoggingEvent event) { - if (!isStarted()) { - return; - } - - try { - ObjectMessage msg = topicSession.createObjectMessage(); - Serializable so = pst.transform(event); - msg.setObject(so); - topicPublisher.publish(msg); - successiveFailureCount = 0; - } catch (Exception e) { - successiveFailureCount++; - if (successiveFailureCount > SUCCESSIVE_FAILURE_LIMIT) { - stop(); - } - addError("Could not publish message in JMSTopicAppender [" + name + "].", e); - } - } - - /** - * Returns the TopicConnection used for this appender. Only valid after - * start() method has been invoked. - */ - protected TopicConnection getTopicConnection() { - return topicConnection; - } - - /** - * Returns the TopicSession used for this appender. Only valid after start() - * method has been invoked. - */ - protected TopicSession getTopicSession() { - return topicSession; - } - - /** - * Returns the TopicPublisher used for this appender. Only valid after start() - * method has been invoked. - */ - protected TopicPublisher getTopicPublisher() { - return topicPublisher; - } -} diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/JMSTopicSink.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.Properties; - -import javax.jms.JMSException; -import javax.jms.ObjectMessage; -import javax.jms.Session; -import javax.jms.Topic; -import javax.jms.TopicConnection; -import javax.jms.TopicConnectionFactory; -import javax.jms.TopicSession; -import javax.jms.TopicSubscriber; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NameNotFoundException; -import javax.naming.NamingException; - -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.classic.util.ContextInitializer; - -/** - * A simple application that consumes logging events sent by a {@link - * JMSTopicAppender}. - * - * @author Ceki Gülcü - */ -public class JMSTopicSink implements javax.jms.MessageListener { - - private Logger logger = (Logger) LoggerFactory.getLogger(JMSTopicSink.class); - - static public void main(String[] args) throws Exception { - if (args.length < 2) { - usage("Wrong number of arguments."); - } - - String tcfBindingName = args[0]; - String topicBindingName = args[1]; - String username = null; - String password = null; - if (args.length == 4) { - username = args[2]; - password = args[3]; - } - - LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); - new ContextInitializer(loggerContext).autoConfig(); - - new JMSTopicSink(tcfBindingName, topicBindingName, username, password); - - BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); - // Loop until the word "exit" is typed - System.out.println("Type \"exit\" to quit JMSTopicSink."); - while (true) { - String s = stdin.readLine(); - if (s.equalsIgnoreCase("exit")) { - System.out.println("Exiting. Kill the application if it does not exit " + "due to daemon threads."); - return; - } - } - } - - public JMSTopicSink(String tcfBindingName, String topicBindingName, String username, String password) { - - try { - Properties env = new Properties(); - env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); - env.put(Context.PROVIDER_URL, "tcp://localhost:61616"); - Context ctx = new InitialContext(env); - TopicConnectionFactory topicConnectionFactory; - topicConnectionFactory = (TopicConnectionFactory) lookup(ctx, tcfBindingName); - System.out.println("Topic Cnx Factory found"); - Topic topic = (Topic) ctx.lookup(topicBindingName); - System.out.println("Topic found: " + topic.getTopicName()); - - TopicConnection topicConnection = topicConnectionFactory.createTopicConnection(username, password); - System.out.println("Topic Connection created"); - - TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); - - TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic); - - topicSubscriber.setMessageListener(this); - - topicConnection.start(); - System.out.println("Topic Connection started"); - - } catch (Exception e) { - logger.error("Could not read JMS message.", e); - } - } - - public void onMessage(javax.jms.Message message) { - ILoggingEvent event; - try { - if (message instanceof ObjectMessage) { - ObjectMessage objectMessage = (ObjectMessage) message; - event = (ILoggingEvent) objectMessage.getObject(); - Logger log = (Logger) LoggerFactory.getLogger(event.getLoggerName()); - log.callAppenders(event); - } else { - logger.warn("Received message is of type " + message.getJMSType() + ", was expecting ObjectMessage."); - } - } catch (JMSException jmse) { - logger.error("Exception thrown while processing incoming message.", jmse); - } - } - - protected Object lookup(Context ctx, String name) throws NamingException { - try { - return ctx.lookup(name); - } catch (NameNotFoundException e) { - logger.error("Could not find name [" + name + "]."); - throw e; - } - } - - static void usage(String msg) { - System.err.println(msg); - System.err.println("Usage: java " + JMSTopicSink.class.getName() + " TopicConnectionFactoryBindingName TopicBindingName Username Password"); - System.exit(1); - } -} diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/server/HardenedLoggingEventInputStream.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/server/HardenedLoggingEventInputStream.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/server/HardenedLoggingEventInputStream.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/server/HardenedLoggingEventInputStream.java 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,56 @@ +package ch.qos.logback.classic.net.server; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import org.slf4j.helpers.BasicMarker; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.spi.ClassPackagingData; +import ch.qos.logback.classic.spi.IThrowableProxy; +import ch.qos.logback.classic.spi.LoggerContextVO; +import ch.qos.logback.classic.spi.LoggerRemoteView; +import ch.qos.logback.classic.spi.LoggingEventVO; +import ch.qos.logback.classic.spi.StackTraceElementProxy; +import ch.qos.logback.classic.spi.ThrowableProxy; +import ch.qos.logback.classic.spi.ThrowableProxyVO; +import ch.qos.logback.core.net.HardenedObjectInputStream; + +public class HardenedLoggingEventInputStream extends HardenedObjectInputStream { + + static final String ARRAY_PREFIX = "[L"; + + static public List getWhilelist() { + List whitelist = new ArrayList(); + whitelist.add(LoggingEventVO.class.getName()); + whitelist.add(LoggerContextVO.class.getName()); + whitelist.add(LoggerRemoteView.class.getName()); + whitelist.add(ThrowableProxyVO.class.getName()); + whitelist.add(BasicMarker.class.getName()); + whitelist.add(Level.class.getName()); + whitelist.add(Logger.class.getName()); + whitelist.add(StackTraceElement.class.getName()); + whitelist.add(StackTraceElement[].class.getName()); + whitelist.add(ThrowableProxy.class.getName()); + whitelist.add(ThrowableProxy[].class.getName()); + whitelist.add(IThrowableProxy.class.getName()); + whitelist.add(IThrowableProxy[].class.getName()); + whitelist.add(StackTraceElementProxy.class.getName()); + whitelist.add(StackTraceElementProxy[].class.getName()); + whitelist.add(ClassPackagingData.class.getName()); + + return whitelist; + } + + public HardenedLoggingEventInputStream(InputStream is) throws IOException { + super(is, getWhilelist()); + } + + public HardenedLoggingEventInputStream(InputStream is, List additionalAuthorizedClasses) throws IOException { + this(is); + super.addToWhitelist(additionalAuthorizedClasses); + } +} diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java 2016-02-25 21:15:39.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/server/RemoteAppenderStreamClient.java 2017-03-30 02:48:10.000000000 +0000 @@ -16,12 +16,12 @@ import java.io.EOFException; import java.io.IOException; import java.io.InputStream; -import java.io.ObjectInputStream; import java.net.Socket; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.net.HardenedObjectInputStream; import ch.qos.logback.core.util.CloseUtil; /** @@ -87,7 +87,7 @@ */ public void run() { logger.info(this + ": connected"); - ObjectInputStream ois = null; + HardenedObjectInputStream ois = null; try { ois = createObjectInputStream(); while (true) { @@ -120,11 +120,11 @@ } } - private ObjectInputStream createObjectInputStream() throws IOException { + private HardenedObjectInputStream createObjectInputStream() throws IOException { if (inputStream != null) { - return new ObjectInputStream(inputStream); + return new HardenedLoggingEventInputStream(inputStream); } - return new ObjectInputStream(socket.getInputStream()); + return new HardenedLoggingEventInputStream(socket.getInputStream()); } /** diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java 2016-02-25 21:15:39.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/SimpleSocketServer.java 2017-03-30 02:48:10.000000000 +0000 @@ -14,7 +14,6 @@ package ch.qos.logback.classic.net; import java.io.IOException; -import java.lang.reflect.Constructor; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java 2016-02-25 21:15:39.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java 2017-03-30 02:48:10.000000000 +0000 @@ -14,8 +14,6 @@ // Contributors: Dan MacDonald package ch.qos.logback.classic.net; -import java.net.InetAddress; - import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.net.AbstractSocketAppender; import ch.qos.logback.core.spi.PreSerializationTransformer; diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java 2016-02-25 21:15:40.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java 2017-03-30 02:48:10.000000000 +0000 @@ -15,13 +15,12 @@ import java.io.BufferedInputStream; import java.io.IOException; -import java.io.ObjectInputStream; import java.net.Socket; import java.net.SocketAddress; import ch.qos.logback.classic.Logger; - import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.net.server.HardenedLoggingEventInputStream; import ch.qos.logback.classic.spi.ILoggingEvent; // Contributors: Moses Hohman @@ -44,7 +43,7 @@ Socket socket; LoggerContext context; - ObjectInputStream ois; + HardenedLoggingEventInputStream hardenedLoggingEventInputStream; SocketAddress remoteSocketAddress; Logger logger; @@ -68,7 +67,7 @@ public void run() { try { - ois = new ObjectInputStream(new BufferedInputStream(socket.getInputStream())); + hardenedLoggingEventInputStream = new HardenedLoggingEventInputStream(new BufferedInputStream(socket.getInputStream())); } catch (Exception e) { logger.error("Could not open ObjectInputStream to " + socket, e); closed = true; @@ -80,7 +79,7 @@ try { while (!closed) { // read an event from the wire - event = (ILoggingEvent) ois.readObject(); + event = (ILoggingEvent) hardenedLoggingEventInputStream.readObject(); // get a logger from the hierarchy. The name of the logger is taken to // be the name contained in the event. remoteLogger = context.getLogger(event.getLoggerName()); @@ -110,13 +109,13 @@ return; } closed = true; - if (ois != null) { + if (hardenedLoggingEventInputStream != null) { try { - ois.close(); + hardenedLoggingEventInputStream.close(); } catch (IOException e) { logger.warn("Could not close connection.", e); } finally { - ois = null; + hardenedLoggingEventInputStream = null; } } } diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java 2016-03-11 21:53:25.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java 2017-03-30 02:48:10.000000000 +0000 @@ -28,6 +28,7 @@ import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.net.server.HardenedLoggingEventInputStream; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.net.DefaultSocketConnector; import ch.qos.logback.core.net.AbstractSocketAppender; @@ -153,9 +154,10 @@ } private void dispatchEvents(LoggerContext lc) { + ObjectInputStream ois = null; try { socket.setSoTimeout(acceptConnectionTimeout); - ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); + ois = new HardenedLoggingEventInputStream(socket.getInputStream()); socket.setSoTimeout(0); addInfo(receiverId + "connection established"); while (true) { @@ -172,6 +174,7 @@ } catch (ClassNotFoundException ex) { addInfo(receiverId + "unknown event class: " + ex); } finally { + CloseUtil.closeQuietly(ois); CloseUtil.closeQuietly(socket); socket = null; addInfo(receiverId + "connection closed"); diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketAppender.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketAppender.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketAppender.java 2016-02-25 21:15:39.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketAppender.java 2017-03-30 02:48:10.000000000 +0000 @@ -13,8 +13,6 @@ */ package ch.qos.logback.classic.net; -import java.net.InetAddress; - import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.net.AbstractSSLSocketAppender; import ch.qos.logback.core.spi.PreSerializationTransformer; diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/pattern/DateConverter.java 2017-03-30 02:48:10.000000000 +0000 @@ -47,7 +47,7 @@ cachingDateFormatter = new CachingDateFormatter(CoreConstants.ISO8601_PATTERN); } - List optionList = getOptionList(); + List optionList = getOptionList(); // if the option list contains a TZ option, then set it. if (optionList != null && optionList.size() > 1) { diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java 2017-03-30 02:48:10.000000000 +0000 @@ -52,7 +52,7 @@ return outputMDCForAllKeys(mdcPropertyMap); } else { - String value = event.getMDCPropertyMap().get(key); + String value = mdcPropertyMap.get(key); if (value != null) { return value; } else { diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java 2016-02-25 21:15:37.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java 2017-03-30 02:48:10.000000000 +0000 @@ -29,6 +29,10 @@ public class ContextDetachingSCL implements ServletContextListener { + public void contextInitialized(ServletContextEvent arg0) { + // do nothing + } + public void contextDestroyed(ServletContextEvent servletContextEvent) { String loggerContextName = null; @@ -59,8 +63,6 @@ } } - public void contextInitialized(ServletContextEvent arg0) { - // do nothing - } + } diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/servlet/LogbackServletContainerInitializer.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/servlet/LogbackServletContainerInitializer.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/servlet/LogbackServletContainerInitializer.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/servlet/LogbackServletContainerInitializer.java 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,66 @@ +package ch.qos.logback.classic.servlet; + +import static ch.qos.logback.core.CoreConstants.DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY; + +import java.util.Set; + +import javax.servlet.ServletContainerInitializer; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; + +import ch.qos.logback.classic.util.StatusViaSLF4JLoggerFactory; +import ch.qos.logback.core.util.OptionHelper; + +/** + * Attaches a new instance of {@link LogbackServletContextListener} to the current web-applications {@link ServletContext}. + * + * @author Ceki Gulcu + * @since 1.1.10 + */ +public class LogbackServletContainerInitializer implements ServletContainerInitializer { + + @Override + public void onStartup(Set> c, ServletContext ctx) throws ServletException { + + if (isDisabledByConfiguration(ctx)) { + StatusViaSLF4JLoggerFactory.addInfo("Due to deployment instructions will NOT register an instance of " + LogbackServletContextListener.class + + " to the current web-app", this); + + return; + } + + StatusViaSLF4JLoggerFactory.addInfo("Adding an instance of " + LogbackServletContextListener.class + " to the current web-app", this); + LogbackServletContextListener lscl = new LogbackServletContextListener(); + ctx.addListener(lscl); + } + + /** + * Search for value of DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY in the web-app first, then as a system property and + * as an environment variable last. + * + * @param ctx + * @return True if value of DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY is available and set to "true", false otherwise. + */ + boolean isDisabledByConfiguration(ServletContext ctx) { + String disableAttributeStr = null; + Object disableAttribute = ctx.getInitParameter(DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY); + if (disableAttribute instanceof String) { + disableAttributeStr = (String) disableAttribute; + } + + if (OptionHelper.isEmpty(disableAttributeStr)) { + disableAttributeStr = OptionHelper.getSystemProperty(DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY); + } + + if (OptionHelper.isEmpty(disableAttributeStr)) { + disableAttributeStr = OptionHelper.getEnv(DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY); + } + + if (OptionHelper.isEmpty(disableAttributeStr)) + return false; + + return disableAttributeStr.equalsIgnoreCase("true"); + + } + +} diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/servlet/LogbackServletContextListener.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/servlet/LogbackServletContextListener.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/servlet/LogbackServletContextListener.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/servlet/LogbackServletContextListener.java 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,40 @@ +package ch.qos.logback.classic.servlet; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import org.slf4j.ILoggerFactory; +import org.slf4j.LoggerFactory; + +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.util.StatusViaSLF4JLoggerFactory; +import ch.qos.logback.core.spi.ContextAwareBase; + +/** + * Allows for graceful shutdown of the {@link LoggerContext} associated with this web-app. + * + * @author Ceki Gulcu + * @since 1.1.10 + */ +public class LogbackServletContextListener implements ServletContextListener { + + ContextAwareBase contextAwareBase = new ContextAwareBase(); + + @Override + public void contextInitialized(ServletContextEvent sce) { + + } + + @Override + public void contextDestroyed(ServletContextEvent sce) { + + ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory(); + if (iLoggerFactory instanceof LoggerContext) { + LoggerContext loggerContext = (LoggerContext) iLoggerFactory; + contextAwareBase.setContext(loggerContext); + StatusViaSLF4JLoggerFactory.addInfo("About to stop " + loggerContext.getClass().getCanonicalName() + " [" + loggerContext.getName() + "]", this); + loggerContext.stop(); + } + } + +} diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java 2016-02-29 19:51:06.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java 2017-03-30 02:48:10.000000000 +0000 @@ -122,12 +122,12 @@ return url; } - url = getResource(GROOVY_AUTOCONFIG_FILE, myClassLoader, updateStatus); + url = getResource(TEST_AUTOCONFIG_FILE, myClassLoader, updateStatus); if (url != null) { return url; } - url = getResource(TEST_AUTOCONFIG_FILE, myClassLoader, updateStatus); + url = getResource(GROOVY_AUTOCONFIG_FILE, myClassLoader, updateStatus); if (url != null) { return url; } diff -Nru logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusViaSLF4JLoggerFactory.java logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusViaSLF4JLoggerFactory.java --- logback-1.1.9/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusViaSLF4JLoggerFactory.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusViaSLF4JLoggerFactory.java 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,40 @@ +package ch.qos.logback.classic.util; + +import org.slf4j.ILoggerFactory; +import org.slf4j.LoggerFactory; + +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.core.spi.ContextAwareBase; +import ch.qos.logback.core.status.ErrorStatus; +import ch.qos.logback.core.status.InfoStatus; +import ch.qos.logback.core.status.Status; + +/** + * Add a status message to the {@link LoggerContext} returned by {@link LoggerFactory#getILoggerFactory}. + * @author ceki + * @since 1.1.10 + */ +public class StatusViaSLF4JLoggerFactory { + + public static void addInfo(String msg, Object o) { + addStatus(new InfoStatus(msg, o)); + } + + public static void addError(String msg, Object o) { + addStatus(new ErrorStatus(msg, o)); + } + + public static void addError(String msg, Object o, Throwable t) { + addStatus(new ErrorStatus(msg, o, t)); + } + + public static void addStatus(Status status) { + ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory(); + if (iLoggerFactory instanceof LoggerContext) { + ContextAwareBase contextAwareBase = new ContextAwareBase(); + LoggerContext loggerContext = (LoggerContext) iLoggerFactory; + contextAwareBase.setContext(loggerContext); + contextAwareBase.addStatus(status); + } + } +} diff -Nru logback-1.1.9/logback-classic/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer logback-1.2.3/logback-classic/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer --- logback-1.1.9/logback-classic/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-classic/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1 @@ +ch.qos.logback.classic.servlet.LogbackServletContainerInitializer \ No newline at end of file diff -Nru logback-1.1.9/logback-classic/src/test/input/issue/logback-1159.xml logback-1.2.3/logback-classic/src/test/input/issue/logback-1159.xml --- logback-1.1.9/logback-classic/src/test/input/issue/logback-1159.xml 2016-05-10 10:28:24.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/input/issue/logback-1159.xml 2017-03-30 02:48:10.000000000 +0000 @@ -1,30 +1,30 @@ - - - - - - - - - - - target/test.log - - - - target/test.${logback.rollingPattern}.log - - 30 - - - %m%n - - - - - - - - + + + + + + + + + + + target/test.log + + + + target/test.${logback.rollingPattern}.log + + 30 + + + %m%n + + + + + + + + diff -Nru logback-1.1.9/logback-classic/src/test/input/joran/compatibility/immediateFlushInEncoder.xml logback-1.2.3/logback-classic/src/test/input/joran/compatibility/immediateFlushInEncoder.xml --- logback-1.1.9/logback-classic/src/test/input/joran/compatibility/immediateFlushInEncoder.xml 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/input/joran/compatibility/immediateFlushInEncoder.xml 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,16 @@ + + + + target/test-output/layoutInsteadOfEncoder.log + true + + + ${immediateFlush} + %msg%n + + + + + + + \ No newline at end of file diff -Nru logback-1.1.9/logback-classic/src/test/input/joran/hostnameProperty.xml logback-1.2.3/logback-classic/src/test/input/joran/hostnameProperty.xml --- logback-1.1.9/logback-classic/src/test/input/joran/hostnameProperty.xml 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/input/joran/hostnameProperty.xml 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,4 @@ + + + + diff -Nru logback-1.1.9/logback-classic/src/test/input/joran/issues/logback-1277.xml logback-1.2.3/logback-classic/src/test/input/joran/issues/logback-1277.xml --- logback-1.1.9/logback-classic/src/test/input/joran/issues/logback-1277.xml 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/input/joran/issues/logback-1277.xml 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,24 @@ + + + + + + + + + /var/log/logbook-%d{yyyy-MM-dd}-%i.log + + 16MB + 2 + 2500MB + + + + %d{"ISO8601","Europe/Berlin"} [%contextName %X{server}] %relative [%thread] %-5level %logger{35} - %msg%n + + + + + + + \ No newline at end of file diff -Nru logback-1.1.9/logback-classic/src/test/input/joran/pattern/replaceNewline.xml logback-1.2.3/logback-classic/src/test/input/joran/pattern/replaceNewline.xml --- logback-1.1.9/logback-classic/src/test/input/joran/pattern/replaceNewline.xml 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/input/joran/pattern/replaceNewline.xml 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + %replace(%msg){'(\n)', '$1${TAB}'} + + + + + + + \ No newline at end of file diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderHSQLTestFixture.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderHSQLTestFixture.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderHSQLTestFixture.java 2016-02-25 21:15:37.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderHSQLTestFixture.java 2017-03-30 02:48:10.000000000 +0000 @@ -22,8 +22,8 @@ import java.util.Properties; import org.hsqldb.Server; -import org.hsqldb.ServerConstants; import org.hsqldb.jdbcDriver; +import org.hsqldb.server.ServerConstants; public class DBAppenderHSQLTestFixture { diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/encoder/LayoutInsteadOfEncoderTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/encoder/LayoutInsteadOfEncoderTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/encoder/LayoutInsteadOfEncoderTest.java 2016-02-25 21:15:39.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/encoder/LayoutInsteadOfEncoderTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -15,6 +15,7 @@ import static ch.qos.logback.core.CoreConstants.CODES_URL; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; @@ -58,4 +59,32 @@ assertTrue(fileAppender.isStarted()); assertTrue(fileAppender.getEncoder() instanceof LayoutWrappingEncoder); } + + @Test + public void immediateFlushInEncoder_TRUE() throws JoranException { + immediateFlushInEncoder(true); + } + + @Test + public void immediateFlushInEncoder_FALSE() throws JoranException { + immediateFlushInEncoder(false); + } + + public void immediateFlushInEncoder(Boolean immediateFlush) throws JoranException { + loggerContext.putProperty("immediateFlush", immediateFlush.toString()); + jc.doConfigure(ClassicTestConstants.JORAN_INPUT_PREFIX + "compatibility/immediateFlushInEncoder.xml"); + StatusPrinter.print(loggerContext); + StatusChecker checker = new StatusChecker(loggerContext); + + checker.assertContainsMatch(Status.WARN, "As of version 1.2.0 \"immediateFlush\" property should be set within the enclosing Appender."); + checker.assertContainsMatch(Status.WARN, "Please move \"immediateFlush\" property into the enclosing appender."); + checker.assertContainsMatch(Status.WARN, "Setting the \"immediateFlush\" property of the enclosing appender to "+immediateFlush); + + ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); + FileAppender fileAppender = (FileAppender) root.getAppender("LIOE"); + assertTrue(fileAppender.isStarted()); + assertEquals(immediateFlush, Boolean.valueOf(fileAppender.isImmediateFlush())); + } + + } diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java 2016-02-25 21:15:37.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -52,15 +52,17 @@ init(baos); String msg = "hello"; ILoggingEvent event = makeLoggingEvent(msg); - ple.doEncode(event); - ple.close(); + byte[] eventBytes = ple.encode(event); + baos.write(eventBytes); + ple.footerBytes(); assertEquals(msg, baos.toString()); } void init(ByteArrayOutputStream baos) throws IOException { ple.start(); ((PatternLayout) ple.getLayout()).setOutputPatternAsHeader(false); - ple.init(baos); + byte[] header = ple.headerBytes(); + baos.write(header); } @Test @@ -69,9 +71,10 @@ init(baos); String msg = "\u03b1"; ILoggingEvent event = makeLoggingEvent(msg); - ple.doEncode(event); - ple.close(); - assertEquals(msg, new String(baos.toByteArray(), utf8Charset.name())); + byte[] eventBytes = ple.encode(event); + baos.write(eventBytes); + ple.footerBytes(); + assertEquals(msg, new String(baos.toByteArray(), utf8Charset)); } } diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/issue/logback_1277/Main.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/issue/logback_1277/Main.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/issue/logback_1277/Main.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/issue/logback_1277/Main.java 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,47 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2015, 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.classic.issue.logback_1277; + +import ch.qos.logback.classic.ClassicTestConstants; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.joran.JoranConfigurator; +import ch.qos.logback.core.joran.spi.JoranException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Main { + + static Logger logger = LoggerFactory.getLogger(Main.class); + static String CONFIG_FILE = ClassicTestConstants.ISSUES_PREFIX + "logback-1277.xml"; + + public static void main(String[] args) throws JoranException, InterruptedException { + init(CONFIG_FILE); + int runLen = 1000 * 1000; + for (int i = 0; i < runLen; i++) { + logger.debug("hello"); + } + System.out.println("Will sleep for 60 seconds"); + Thread.sleep(1000 * 60); + System.out.println("Exiting"); + + } + + static void init(String file) throws JoranException { + LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); + JoranConfigurator jc = new JoranConfigurator(); + jc.setContext(loggerContext); + loggerContext.reset(); + jc.doConfigure(file); + } +} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java 2016-03-29 19:36:31.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -390,7 +390,6 @@ @Test public void properties() throws JoranException { String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "properties.xml"; - assertNull(loggerContext.getProperty(CoreConstants.HOSTNAME_KEY)); assertNull(System.getProperty("sys")); configure(configFileAsStr); @@ -403,6 +402,13 @@ checker.assertIsErrorFree(); } + @Test + public void hostnameProperty() throws JoranException { + String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "hostnameProperty.xml"; + configure(configFileAsStr); + assertEquals("A", loggerContext.getProperty(CoreConstants.HOSTNAME_KEY)); + } + // see also http://jira.qos.ch/browse/LBCORE-254 @Test public void sysProps() throws JoranException { @@ -427,8 +433,7 @@ configure(configFileAsStr); assertTrue(loggerContext.isPackagingDataEnabled()); } - - + @Test public void valueOfConvention() throws JoranException { String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX + "valueOfConvention.xml"; diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/LoggerSerializationTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/LoggerSerializationTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/LoggerSerializationTest.java 2016-02-25 21:15:40.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/LoggerSerializationTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -13,16 +13,25 @@ */ package ch.qos.logback.classic; -import java.io.*; +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.List; -import ch.qos.logback.core.util.CoreTestConstants; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.slf4j.LoggerFactory; -import static junit.framework.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import ch.qos.logback.classic.net.server.HardenedLoggingEventInputStream; +import ch.qos.logback.core.net.HardenedObjectInputStream; +import ch.qos.logback.core.util.CoreTestConstants; public class LoggerSerializationTest { @@ -35,8 +44,9 @@ ByteArrayOutputStream bos; ObjectOutputStream oos; - ObjectInputStream inputStream; - + HardenedLoggingEventInputStream hardenedLoggingEventInputStream; + List whitelist = new ArrayList(); + @Before public void setUp() throws Exception { lc = new LoggerContext(); @@ -45,6 +55,7 @@ // create the byte output stream bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); + whitelist.add(Foo.class.getName()); } @After @@ -110,17 +121,17 @@ private Foo writeAndRead(Foo foo) throws IOException, ClassNotFoundException { writeObject(oos, foo); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - inputStream = new ObjectInputStream(bis); - Foo fooBack = readFooObject(inputStream); - inputStream.close(); + hardenedLoggingEventInputStream = new HardenedLoggingEventInputStream(bis, whitelist); + Foo fooBack = readFooObject(hardenedLoggingEventInputStream); + hardenedLoggingEventInputStream.close(); return fooBack; } - Foo readFooObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException { + Foo readFooObject(HardenedObjectInputStream inputStream) throws IOException, ClassNotFoundException { return (Foo) readObject(inputStream); } - private Object readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException { + private Object readObject(HardenedObjectInputStream inputStream) throws IOException, ClassNotFoundException { return inputStream.readObject(); } @@ -133,7 +144,7 @@ @Test public void testCompatibilityWith_v1_0_11() throws IOException, ClassNotFoundException { FileInputStream fis = new FileInputStream(SERIALIZATION_PREFIX + "logger_v1.0.11.ser"); - ObjectInputStream ois = new ObjectInputStream(fis); + HardenedObjectInputStream ois = new HardenedLoggingEventInputStream(fis); // new String[] {Logger.class.getName(), LoggerRemoteView.class.getName()}); Logger a = (Logger) ois.readObject(); ois.close(); assertEquals("a", a.getName()); @@ -145,7 +156,7 @@ @Test public void testCompatibilityWith_v1_0_12() throws IOException, ClassNotFoundException { FileInputStream fis = new FileInputStream(SERIALIZATION_PREFIX + "logger_v1.0.12.ser"); - ObjectInputStream ois = new ObjectInputStream(fis); + HardenedObjectInputStream ois = new HardenedObjectInputStream(fis, new String[] {Logger.class.getName()}); Logger a = (Logger) ois.readObject(); ois.close(); assertEquals("a", a.getName()); diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTestApp.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTestApp.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTestApp.java 2016-02-25 21:15:39.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTestApp.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net; - -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.core.util.StatusPrinter; - -public class JMSQueueAppenderTestApp { - - public static void main(String[] args) { - Logger logger = (Logger) LoggerFactory.getLogger(JMSTopicAppenderTestApp.class); - LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); - lc.reset(); - - JMSQueueAppender appender = new JMSQueueAppender(); - appender.setContext(lc); - appender.setName("jmsQueue"); - appender.setInitialContextFactoryName("org.apache.activemq.jndi.ActiveMQInitialContextFactory"); - // appender.setPassword(""); - appender.setProviderURL("tcp://localhost:61616"); - // appender.setSecurityCredentials(""); - // appender.setSecurityPrincipalName(""); - appender.setQueueBindingName("MyQueue"); - appender.setQueueConnectionFactoryBindingName("ConnectionFactory"); - // appender.setURLPkgPrefixes(""); - // appender.setUserName(""); - - appender.start(); - logger.addAppender(appender); - - // JIT - for (int i = 0; i < 10000; i++) { - logger.debug("** Hello world. n=" + i); - } - - long before = System.nanoTime(); - for (int i = 0; i < 10000; i++) { - logger.debug("** Hello world. n=" + i); - } - long after = System.nanoTime(); - - System.out.println("Time per logs for 10'000 logs: " + (after - before) / 10000); - - StatusPrinter.print(lc.getStatusManager()); - } - -} \ No newline at end of file diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTest.java 2016-02-25 21:15:40.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSQueueAppenderTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net; - -import java.io.Serializable; - -import javax.jms.ObjectMessage; - -import junit.framework.TestCase; -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.net.mock.MockQueue; -import ch.qos.logback.classic.net.mock.MockQueueConnectionFactory; -import ch.qos.logback.classic.net.mock.MockQueueSender; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.classic.spi.LoggingEvent; -import ch.qos.logback.classic.util.MockInitialContext; -import ch.qos.logback.classic.util.MockInitialContextFactory; -import ch.qos.logback.core.ContextBase; -import ch.qos.logback.core.spi.PreSerializationTransformer; - -public class JMSQueueAppenderTest extends TestCase { - - ch.qos.logback.core.Context context; - JMSQueueAppender appender; - PreSerializationTransformer pst = new LoggingEventPreSerializationTransformer(); - - @Override - protected void setUp() throws Exception { - context = new ContextBase(); - appender = new JMSQueueAppender(); - appender.setContext(context); - appender.setName("jmsQueue"); - appender.qcfBindingName = "queueCnxFactory"; - appender.queueBindingName = "testQueue"; - appender.setProviderURL("url"); - appender.setInitialContextFactoryName(MockInitialContextFactory.class.getName()); - - MockInitialContext mic = MockInitialContextFactory.getContext(); - mic.map.put(appender.qcfBindingName, new MockQueueConnectionFactory()); - mic.map.put(appender.queueBindingName, new MockQueue(appender.queueBindingName)); - - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - appender = null; - context = null; - super.tearDown(); - } - - public void testAppendOk() { - appender.start(); - - ILoggingEvent le = createLoggingEvent(); - appender.append(le); - - MockQueueSender qs = (MockQueueSender) appender.queueSender; - assertEquals(1, qs.getMessageList().size()); - ObjectMessage message = (ObjectMessage) qs.getMessageList().get(0); - try { - Serializable witness = pst.transform(le); - assertEquals(witness, message.getObject()); - } catch (Exception e) { - fail(); - } - } - - public void testAppendFailure() { - appender.start(); - - // make sure the append method does not work - appender.queueSender = null; - - ILoggingEvent le = createLoggingEvent(); - for (int i = 1; i <= 3; i++) { - appender.append(le); - assertEquals(i, context.getStatusManager().getCount()); - assertTrue(appender.isStarted()); - } - appender.append(le); - assertEquals(4, context.getStatusManager().getCount()); - assertFalse(appender.isStarted()); - } - - public void testStartMinimalInfo() { - // let's leave only what's in the setup() - // method, minus the providerURL - appender.setProviderURL(null); - appender.start(); - - assertTrue(appender.isStarted()); - - try { - assertEquals(appender.queueBindingName, appender.queueSender.getQueue().getQueueName()); - } catch (Exception e) { - fail(); - } - } - - public void testStartUserPass() { - appender.setUserName("test"); - appender.setPassword("test"); - - appender.start(); - - assertTrue(appender.isStarted()); - - try { - assertEquals(appender.queueBindingName, appender.queueSender.getQueue().getQueueName()); - } catch (Exception e) { - fail(); - } - } - - public void testStartFails() { - appender.queueBindingName = null; - - appender.start(); - - assertFalse(appender.isStarted()); - } - - private ILoggingEvent createLoggingEvent() { - LoggingEvent le = new LoggingEvent(); - le.setLevel(Level.DEBUG); - le.setMessage("test message"); - le.setTimeStamp(System.currentTimeMillis()); - le.setThreadName(Thread.currentThread().getName()); - return le; - } -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTestApp.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTestApp.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTestApp.java 2016-02-25 21:15:37.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTestApp.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net; - -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.core.util.StatusPrinter; - -public class JMSTopicAppenderTestApp { - - public static void main(String[] args) { - Logger logger = (Logger) LoggerFactory.getLogger(JMSTopicAppenderTestApp.class); - LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); - lc.reset(); - - JMSTopicAppender appender = new JMSTopicAppender(); - appender.setContext(lc); - appender.setName("jmsTopic"); - appender.setInitialContextFactoryName("org.apache.activemq.jndi.ActiveMQInitialContextFactory"); - // appender.setPassword(""); - appender.setProviderURL("tcp://localhost:61616"); - // appender.setSecurityCredentials(""); - // appender.setSecurityPrincipalName(""); - appender.setTopicBindingName("MyTopic"); - appender.setTopicConnectionFactoryBindingName("ConnectionFactory"); - // appender.setURLPkgPrefixes(""); - // appender.setUserName(""); - - appender.start(); - logger.addAppender(appender); - - // JIT - for (int i = 0; i < 10000; i++) { - logger.debug("** Hello world. n=" + i); - } - - long before = System.nanoTime(); - for (int i = 0; i < 10000; i++) { - logger.debug("** Hello world. n=" + i); - } - long after = System.nanoTime(); - - System.out.println("Time per logs for 10'000 logs: " + (after - before) / 10000); - - StatusPrinter.print(lc.getStatusManager()); - } - -} \ No newline at end of file diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTest.java 2016-02-25 21:15:39.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/JMSTopicAppenderTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,230 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net; - -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.Serializable; -import java.util.Properties; - -import javax.jms.ObjectMessage; -import javax.naming.Context; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.net.mock.MockTopic; -import ch.qos.logback.classic.net.mock.MockTopicConnectionFactory; -import ch.qos.logback.classic.net.mock.MockTopicPublisher; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.classic.spi.LoggingEvent; -import ch.qos.logback.classic.util.MockInitialContext; -import ch.qos.logback.classic.util.MockInitialContextFactory; -import ch.qos.logback.core.ContextBase; -import ch.qos.logback.core.spi.PreSerializationTransformer; - -public class JMSTopicAppenderTest { - - ch.qos.logback.core.Context context; - JMSTopicAppender appender; - PreSerializationTransformer pst = new LoggingEventPreSerializationTransformer(); - - @Before - public void setUp() throws Exception { - context = new ContextBase(); - appender = new JMSTopicAppender(); - appender.setContext(context); - appender.setName("jmsTopic"); - appender.tcfBindingName = "topicCnxFactory"; - appender.topicBindingName = "testTopic"; - appender.setProviderURL("url"); - appender.setInitialContextFactoryName(MockInitialContextFactory.class.getName()); - - MockInitialContext mic = MockInitialContextFactory.getContext(); - mic.map.put(appender.tcfBindingName, new MockTopicConnectionFactory()); - mic.map.put(appender.topicBindingName, new MockTopic(appender.topicBindingName)); - - } - - @After - public void tearDown() throws Exception { - appender = null; - context = null; - } - - @Test - public void testAppendOk() { - appender.start(); - - ILoggingEvent le = createLoggingEvent(); - appender.append(le); - - MockTopicPublisher tp = (MockTopicPublisher) appender.topicPublisher; - assertEquals(1, tp.getMessageList().size()); - ObjectMessage message = (ObjectMessage) tp.getMessageList().get(0); - try { - Serializable witness = pst.transform(le); - assertEquals(witness, message.getObject()); - } catch (Exception e) { - fail(); - } - } - - @Test - public void testAppendFailure() { - appender.start(); - - // make sure the append method does not work - appender.topicPublisher = null; - - ILoggingEvent le = createLoggingEvent(); - for (int i = 1; i <= 3; i++) { - appender.append(le); - assertEquals(i, context.getStatusManager().getCount()); - assertTrue(appender.isStarted()); - } - appender.append(le); - assertEquals(4, context.getStatusManager().getCount()); - assertFalse(appender.isStarted()); - } - - @Test - public void testBuildEnvProperties() { - appender.setInitialContextFactoryName("icfn"); - appender.setProviderURL("url"); - appender.setURLPkgPrefixes("pkgPref"); - appender.setSecurityPrincipalName("user"); - appender.setSecurityCredentials("cred"); - - Properties props = appender.buildEnvProperties(); - assertEquals(5, props.size()); - assertEquals(appender.getInitialContextFactoryName(), props.getProperty(Context.INITIAL_CONTEXT_FACTORY)); - assertEquals(appender.getProviderURL(), props.getProperty(Context.PROVIDER_URL)); - assertEquals(appender.getURLPkgPrefixes(), props.getProperty(Context.URL_PKG_PREFIXES)); - assertEquals(appender.getSecurityPrincipalName(), props.getProperty(Context.SECURITY_PRINCIPAL)); - assertEquals(appender.getSecurityCredentials(), props.getProperty(Context.SECURITY_CREDENTIALS)); - } - - @Test - public void testBuildEnvPropertiesWithNullProviderURL() { - appender.setInitialContextFactoryName("icfn"); - appender.setProviderURL(null); - appender.setURLPkgPrefixes("pkgPref"); - appender.setSecurityPrincipalName("user"); - appender.setSecurityCredentials("cred"); - - Properties props = appender.buildEnvProperties(); - assertEquals(4, props.size()); - assertEquals(appender.getInitialContextFactoryName(), props.getProperty(Context.INITIAL_CONTEXT_FACTORY)); - assertEquals(null, props.getProperty(Context.PROVIDER_URL)); - assertEquals(appender.getURLPkgPrefixes(), props.getProperty(Context.URL_PKG_PREFIXES)); - assertEquals(appender.getSecurityPrincipalName(), props.getProperty(Context.SECURITY_PRINCIPAL)); - assertEquals(appender.getSecurityCredentials(), props.getProperty(Context.SECURITY_CREDENTIALS)); - - assertEquals(1, context.getStatusManager().getCount()); - } - - @Test - public void testBuildEnvPropertiesWithNullCredentials() { - appender.setInitialContextFactoryName("icfn"); - appender.setProviderURL("url"); - appender.setURLPkgPrefixes("pkgPref"); - appender.setSecurityPrincipalName("user"); - appender.setSecurityCredentials(null); - - Properties props = appender.buildEnvProperties(); - assertEquals(4, props.size()); - assertEquals(appender.getInitialContextFactoryName(), props.getProperty(Context.INITIAL_CONTEXT_FACTORY)); - assertEquals(appender.getProviderURL(), props.getProperty(Context.PROVIDER_URL)); - assertEquals(appender.getURLPkgPrefixes(), props.getProperty(Context.URL_PKG_PREFIXES)); - assertEquals(appender.getSecurityPrincipalName(), props.getProperty(Context.SECURITY_PRINCIPAL)); - assertEquals(null, props.getProperty(Context.SECURITY_CREDENTIALS)); - - assertEquals(1, context.getStatusManager().getCount()); - } - - @Test - public void testBuildEnvPropertiesWithPkgNull() { - appender.setInitialContextFactoryName("icfn"); - appender.setProviderURL("url"); - appender.setURLPkgPrefixes(null); - appender.setSecurityPrincipalName("user"); - appender.setSecurityCredentials("cred"); - - Properties props = appender.buildEnvProperties(); - assertEquals(4, props.size()); - assertEquals(appender.getInitialContextFactoryName(), props.getProperty(Context.INITIAL_CONTEXT_FACTORY)); - assertEquals(appender.getProviderURL(), props.getProperty(Context.PROVIDER_URL)); - assertEquals(null, props.getProperty(Context.URL_PKG_PREFIXES)); - assertEquals(appender.getSecurityPrincipalName(), props.getProperty(Context.SECURITY_PRINCIPAL)); - assertEquals(appender.getSecurityCredentials(), props.getProperty(Context.SECURITY_CREDENTIALS)); - - assertEquals(0, context.getStatusManager().getCount()); - } - - @Test - public void testStartMinimalInfo() { - // let's leave only what's in the setup() - // method, minus the providerURL - appender.setProviderURL(null); - appender.start(); - - assertTrue(appender.isStarted()); - - try { - assertEquals(appender.topicBindingName, appender.topicPublisher.getTopic().getTopicName()); - } catch (Exception e) { - fail(); - } - } - - @Test - public void testStartUserPass() { - appender.setUserName("test"); - appender.setPassword("test"); - - appender.start(); - - assertTrue(appender.isStarted()); - - try { - assertEquals(appender.topicBindingName, appender.topicPublisher.getTopic().getTopicName()); - } catch (Exception e) { - fail(); - } - } - - @Test - public void testStartFails() { - appender.topicBindingName = null; - - appender.start(); - - assertFalse(appender.isStarted()); - } - - private ILoggingEvent createLoggingEvent() { - LoggingEvent le = new LoggingEvent(); - le.setLevel(Level.DEBUG); - le.setMessage("test message"); - le.setTimeStamp(System.currentTimeMillis()); - le.setThreadName(Thread.currentThread().getName()); - return le; - } -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockObjectMessage.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockObjectMessage.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockObjectMessage.java 2016-02-25 21:15:37.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockObjectMessage.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,237 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net.mock; - -import java.io.Serializable; -import java.util.Enumeration; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.ObjectMessage; - -public class MockObjectMessage implements ObjectMessage { - - Serializable object; - - public Serializable getObject() throws JMSException { - return object; - } - - public void setObject(Serializable object) throws JMSException { - this.object = object; - } - - public void acknowledge() throws JMSException { - - } - - public void clearBody() throws JMSException { - - } - - public void clearProperties() throws JMSException { - - } - - public boolean getBooleanProperty(String arg0) throws JMSException { - - return false; - } - - public byte getByteProperty(String arg0) throws JMSException { - - return 0; - } - - public double getDoubleProperty(String arg0) throws JMSException { - - return 0; - } - - public float getFloatProperty(String arg0) throws JMSException { - - return 0; - } - - public int getIntProperty(String arg0) throws JMSException { - - return 0; - } - - public String getJMSCorrelationID() throws JMSException { - - return null; - } - - public byte[] getJMSCorrelationIDAsBytes() throws JMSException { - - return null; - } - - public int getJMSDeliveryMode() throws JMSException { - - return 0; - } - - public Destination getJMSDestination() throws JMSException { - - return null; - } - - public long getJMSExpiration() throws JMSException { - - return 0; - } - - public String getJMSMessageID() throws JMSException { - - return null; - } - - public int getJMSPriority() throws JMSException { - - return 0; - } - - public boolean getJMSRedelivered() throws JMSException { - - return false; - } - - public Destination getJMSReplyTo() throws JMSException { - - return null; - } - - public long getJMSTimestamp() throws JMSException { - - return 0; - } - - public String getJMSType() throws JMSException { - - return null; - } - - public long getLongProperty(String arg0) throws JMSException { - - return 0; - } - - public Object getObjectProperty(String arg0) throws JMSException { - - return null; - } - - public Enumeration getPropertyNames() throws JMSException { - - return null; - } - - public short getShortProperty(String arg0) throws JMSException { - - return 0; - } - - public String getStringProperty(String arg0) throws JMSException { - - return null; - } - - public boolean propertyExists(String arg0) throws JMSException { - - return false; - } - - public void setBooleanProperty(String arg0, boolean arg1) throws JMSException { - - } - - public void setByteProperty(String arg0, byte arg1) throws JMSException { - - } - - public void setDoubleProperty(String arg0, double arg1) throws JMSException { - - } - - public void setFloatProperty(String arg0, float arg1) throws JMSException { - - } - - public void setIntProperty(String arg0, int arg1) throws JMSException { - - } - - public void setJMSCorrelationID(String arg0) throws JMSException { - - } - - public void setJMSCorrelationIDAsBytes(byte[] arg0) throws JMSException { - - } - - public void setJMSDeliveryMode(int arg0) throws JMSException { - - } - - public void setJMSDestination(Destination arg0) throws JMSException { - - } - - public void setJMSExpiration(long arg0) throws JMSException { - - } - - public void setJMSMessageID(String arg0) throws JMSException { - - } - - public void setJMSPriority(int arg0) throws JMSException { - - } - - public void setJMSRedelivered(boolean arg0) throws JMSException { - - } - - public void setJMSReplyTo(Destination arg0) throws JMSException { - - } - - public void setJMSTimestamp(long arg0) throws JMSException { - - } - - public void setJMSType(String arg0) throws JMSException { - - } - - public void setLongProperty(String arg0, long arg1) throws JMSException { - - } - - public void setObjectProperty(String arg0, Object arg1) throws JMSException { - - } - - public void setShortProperty(String arg0, short arg1) throws JMSException { - - } - - public void setStringProperty(String arg0, String arg1) throws JMSException { - - } - -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnectionFactory.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnectionFactory.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnectionFactory.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnectionFactory.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net.mock; - -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.QueueConnection; -import javax.jms.QueueConnectionFactory; - -public class MockQueueConnectionFactory implements QueueConnectionFactory { - - MockQueueConnection cnx = new MockQueueConnection(); - - public QueueConnection createQueueConnection() throws JMSException { - return cnx; - } - - public QueueConnection createQueueConnection(String user, String pass) throws JMSException { - - return cnx; - } - - public Connection createConnection() throws JMSException { - return null; - } - - public Connection createConnection(String arg0, String arg1) throws JMSException { - return null; - } - -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnection.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnection.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnection.java 2016-02-25 21:15:40.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueConnection.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net.mock; - -import javax.jms.ConnectionConsumer; -import javax.jms.ConnectionMetaData; -import javax.jms.Destination; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.Queue; -import javax.jms.QueueConnection; -import javax.jms.QueueSession; -import javax.jms.ServerSessionPool; -import javax.jms.Session; -import javax.jms.Topic; - -public class MockQueueConnection implements QueueConnection { - - MockQueueSession session = new MockQueueSession(); - - public QueueSession createQueueSession(boolean arg0, int arg1) throws JMSException { - return session; - } - - public ConnectionConsumer createConnectionConsumer(Queue arg0, String arg1, ServerSessionPool arg2, int arg3) throws JMSException { - - return null; - } - - public void close() throws JMSException { - - } - - public ConnectionConsumer createConnectionConsumer(Destination arg0, String arg1, ServerSessionPool arg2, int arg3) throws JMSException { - - return null; - } - - public ConnectionConsumer createDurableConnectionConsumer(Topic arg0, String arg1, String arg2, ServerSessionPool arg3, int arg4) throws JMSException { - - return null; - } - - public Session createSession(boolean arg0, int arg1) throws JMSException { - - return null; - } - - public String getClientID() throws JMSException { - - return null; - } - - public ExceptionListener getExceptionListener() throws JMSException { - - return null; - } - - public ConnectionMetaData getMetaData() throws JMSException { - - return null; - } - - public void setClientID(String arg0) throws JMSException { - - } - - public void setExceptionListener(ExceptionListener arg0) throws JMSException { - - } - - public void start() throws JMSException { - - } - - public void stop() throws JMSException { - - } - -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueue.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueue.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueue.java 2016-02-25 21:15:40.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueue.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net.mock; - -import javax.jms.JMSException; -import javax.jms.Queue; - -public class MockQueue implements Queue { - - String name; - - public MockQueue(String name) { - this.name = name; - } - - public String getQueueName() throws JMSException { - return name; - } - -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSender.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSender.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSender.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSender.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net.mock; - -import java.util.ArrayList; -import java.util.List; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Queue; -import javax.jms.QueueSender; - -public class MockQueueSender implements QueueSender { - - List messageList = new ArrayList(); - Queue queue; - - public MockQueueSender(Queue queue) { - this.queue = queue; - } - - public List getMessageList() { - return messageList; - } - - public Queue getQueue() throws JMSException { - return queue; - } - - public void send(Message message) throws JMSException { - messageList.add(message); - - } - - public void send(Queue arg0, Message arg1) throws JMSException { - - } - - public void send(Message arg0, int arg1, int arg2, long arg3) throws JMSException { - - } - - public void send(Queue arg0, Message arg1, int arg2, int arg3, long arg4) throws JMSException { - - } - - public void close() throws JMSException { - - } - - public int getDeliveryMode() throws JMSException { - - return 0; - } - - public Destination getDestination() throws JMSException { - - return null; - } - - public boolean getDisableMessageID() throws JMSException { - - return false; - } - - public boolean getDisableMessageTimestamp() throws JMSException { - - return false; - } - - public int getPriority() throws JMSException { - - return 0; - } - - public long getTimeToLive() throws JMSException { - - return 0; - } - - public void send(Destination arg0, Message arg1) throws JMSException { - - } - - public void send(Destination arg0, Message arg1, int arg2, int arg3, long arg4) throws JMSException { - - } - - public void setDeliveryMode(int arg0) throws JMSException { - - } - - public void setDisableMessageID(boolean arg0) throws JMSException { - - } - - public void setDisableMessageTimestamp(boolean arg0) throws JMSException { - - } - - public void setPriority(int arg0) throws JMSException { - - } - - public void setTimeToLive(long arg0) throws JMSException { - - } - -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSession.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSession.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSession.java 2016-02-25 21:15:39.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockQueueSession.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,200 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net.mock; - -import java.io.Serializable; - -import javax.jms.BytesMessage; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MapMessage; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Queue; -import javax.jms.QueueBrowser; -import javax.jms.QueueReceiver; -import javax.jms.QueueSender; -import javax.jms.QueueSession; -import javax.jms.StreamMessage; -import javax.jms.TemporaryQueue; -import javax.jms.TemporaryTopic; -import javax.jms.TextMessage; -import javax.jms.Topic; -import javax.jms.TopicSubscriber; - -public class MockQueueSession implements QueueSession { - - public ObjectMessage createObjectMessage() throws JMSException { - return new MockObjectMessage(); - } - - public QueueSender createSender(Queue queue) throws JMSException { - if (queue == null) { - return null; - } - return new MockQueueSender(queue); - } - - public QueueBrowser createBrowser(Queue arg0) throws JMSException { - - return null; - } - - public QueueBrowser createBrowser(Queue arg0, String arg1) throws JMSException { - - return null; - } - - public Queue createQueue(String arg0) throws JMSException { - - return null; - } - - public QueueReceiver createReceiver(Queue arg0) throws JMSException { - - return null; - } - - public QueueReceiver createReceiver(Queue arg0, String arg1) throws JMSException { - - return null; - } - - public TemporaryQueue createTemporaryQueue() throws JMSException { - - return null; - } - - public void close() throws JMSException { - - } - - public void commit() throws JMSException { - - } - - public BytesMessage createBytesMessage() throws JMSException { - - return null; - } - - public MessageConsumer createConsumer(Destination arg0) throws JMSException { - - return null; - } - - public MessageConsumer createConsumer(Destination arg0, String arg1) throws JMSException { - - return null; - } - - public MessageConsumer createConsumer(Destination arg0, String arg1, boolean arg2) throws JMSException { - - return null; - } - - public TopicSubscriber createDurableSubscriber(Topic arg0, String arg1) throws JMSException { - - return null; - } - - public TopicSubscriber createDurableSubscriber(Topic arg0, String arg1, String arg2, boolean arg3) throws JMSException { - - return null; - } - - public MapMessage createMapMessage() throws JMSException { - - return null; - } - - public Message createMessage() throws JMSException { - - return null; - } - - public ObjectMessage createObjectMessage(Serializable arg0) throws JMSException { - - return null; - } - - public MessageProducer createProducer(Destination arg0) throws JMSException { - - return null; - } - - public StreamMessage createStreamMessage() throws JMSException { - - return null; - } - - public TemporaryTopic createTemporaryTopic() throws JMSException { - - return null; - } - - public TextMessage createTextMessage() throws JMSException { - - return null; - } - - public TextMessage createTextMessage(String arg0) throws JMSException { - - return null; - } - - public Topic createTopic(String arg0) throws JMSException { - - return null; - } - - public int getAcknowledgeMode() throws JMSException { - - return 0; - } - - public MessageListener getMessageListener() throws JMSException { - - return null; - } - - public boolean getTransacted() throws JMSException { - - return false; - } - - public void recover() throws JMSException { - - } - - public void rollback() throws JMSException { - - } - - public void run() { - - } - - public void setMessageListener(MessageListener arg0) throws JMSException { - - } - - public void unsubscribe(String arg0) throws JMSException { - - } - -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnectionFactory.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnectionFactory.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnectionFactory.java 2016-02-25 21:15:37.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnectionFactory.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net.mock; - -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.TopicConnection; -import javax.jms.TopicConnectionFactory; - -public class MockTopicConnectionFactory implements TopicConnectionFactory { - - MockTopicConnection cnx = new MockTopicConnection(); - - public TopicConnection createTopicConnection() throws JMSException { - return cnx; - } - - public TopicConnection createTopicConnection(String user, String pass) throws JMSException { - - return cnx; - } - - public Connection createConnection() throws JMSException { - return null; - } - - public Connection createConnection(String arg0, String arg1) throws JMSException { - return null; - } - -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnection.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnection.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnection.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicConnection.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net.mock; - -import javax.jms.ConnectionConsumer; -import javax.jms.ConnectionMetaData; -import javax.jms.Destination; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.ServerSessionPool; -import javax.jms.Session; -import javax.jms.Topic; -import javax.jms.TopicConnection; -import javax.jms.TopicSession; - -public class MockTopicConnection implements TopicConnection { - - MockTopicSession session = new MockTopicSession(); - - public TopicSession createTopicSession(boolean arg0, int arg1) throws JMSException { - return session; - } - - public ConnectionConsumer createConnectionConsumer(Topic arg0, String arg1, ServerSessionPool arg2, int arg3) throws JMSException { - - return null; - } - - public ConnectionConsumer createDurableConnectionConsumer(Topic arg0, String arg1, String arg2, ServerSessionPool arg3, int arg4) throws JMSException { - - return null; - } - - public void close() throws JMSException { - - } - - public ConnectionConsumer createConnectionConsumer(Destination arg0, String arg1, ServerSessionPool arg2, int arg3) throws JMSException { - - return null; - } - - public Session createSession(boolean arg0, int arg1) throws JMSException { - - return null; - } - - public String getClientID() throws JMSException { - - return null; - } - - public ExceptionListener getExceptionListener() throws JMSException { - - return null; - } - - public ConnectionMetaData getMetaData() throws JMSException { - - return null; - } - - public void setClientID(String arg0) throws JMSException { - - } - - public void setExceptionListener(ExceptionListener arg0) throws JMSException { - - } - - public void start() throws JMSException { - - } - - public void stop() throws JMSException { - - } - -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopic.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopic.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopic.java 2016-02-25 21:15:37.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopic.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net.mock; - -import javax.jms.JMSException; -import javax.jms.Topic; - -public class MockTopic implements Topic { - - String name; - - public MockTopic(String name) { - this.name = name; - } - - public String getTopicName() throws JMSException { - return name; - } - -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicPublisher.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicPublisher.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicPublisher.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicPublisher.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net.mock; - -import java.util.ArrayList; -import java.util.List; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Topic; -import javax.jms.TopicPublisher; - -public class MockTopicPublisher implements TopicPublisher { - - List messageList = new ArrayList(); - Topic topic; - - public MockTopicPublisher(Topic topic) { - this.topic = topic; - } - - public void publish(Message message) throws JMSException { - messageList.add(message); - } - - public List getMessageList() { - return messageList; - } - - public Topic getTopic() throws JMSException { - return topic; - } - - public void publish(Message arg0, int arg1, int arg2, long arg3) throws JMSException { - - } - - public void publish(Topic arg0, Message arg1, int arg2, int arg3, long arg4) throws JMSException { - - } - - public void publish(Topic arg0, Message arg1) throws JMSException { - - } - - public void close() throws JMSException { - - } - - public int getDeliveryMode() throws JMSException { - - return 0; - } - - public Destination getDestination() throws JMSException { - - return null; - } - - public boolean getDisableMessageID() throws JMSException { - - return false; - } - - public boolean getDisableMessageTimestamp() throws JMSException { - - return false; - } - - public int getPriority() throws JMSException { - - return 0; - } - - public long getTimeToLive() throws JMSException { - - return 0; - } - - public void send(Destination arg0, Message arg1, int arg2, int arg3, long arg4) throws JMSException { - - } - - public void send(Destination arg0, Message arg1) throws JMSException { - - } - - public void send(Message arg0, int arg1, int arg2, long arg3) throws JMSException { - - } - - public void send(Message arg0) throws JMSException { - - } - - public void setDeliveryMode(int arg0) throws JMSException { - - } - - public void setDisableMessageID(boolean arg0) throws JMSException { - - } - - public void setDisableMessageTimestamp(boolean arg0) throws JMSException { - - } - - public void setPriority(int arg0) throws JMSException { - - } - - public void setTimeToLive(long arg0) throws JMSException { - - } - -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicSession.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicSession.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicSession.java 2016-02-25 21:15:37.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockTopicSession.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,193 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.classic.net.mock; - -import java.io.Serializable; - -import javax.jms.BytesMessage; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MapMessage; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Queue; -import javax.jms.QueueBrowser; -import javax.jms.StreamMessage; -import javax.jms.TemporaryQueue; -import javax.jms.TemporaryTopic; -import javax.jms.TextMessage; -import javax.jms.Topic; -import javax.jms.TopicPublisher; -import javax.jms.TopicSession; -import javax.jms.TopicSubscriber; - -public class MockTopicSession implements TopicSession { - - public ObjectMessage createObjectMessage() throws JMSException { - return new MockObjectMessage(); - } - - public TopicPublisher createPublisher(Topic topic) throws JMSException { - if (topic == null) { - return null; - } - return new MockTopicPublisher(topic); - } - - public TopicSubscriber createDurableSubscriber(Topic arg0, String arg1) throws JMSException { - return null; - } - - public TopicSubscriber createDurableSubscriber(Topic arg0, String arg1, String arg2, boolean arg3) throws JMSException { - return null; - } - - public TopicSubscriber createSubscriber(Topic arg0) throws JMSException { - return null; - } - - public TopicSubscriber createSubscriber(Topic arg0, String arg1, boolean arg2) throws JMSException { - return null; - } - - public TemporaryTopic createTemporaryTopic() throws JMSException { - return null; - } - - public Topic createTopic(String arg0) throws JMSException { - return null; - } - - public void unsubscribe(String arg0) throws JMSException { - - } - - public void close() throws JMSException { - - } - - public void commit() throws JMSException { - - } - - public QueueBrowser createBrowser(Queue arg0) throws JMSException { - - return null; - } - - public QueueBrowser createBrowser(Queue arg0, String arg1) throws JMSException { - - return null; - } - - public BytesMessage createBytesMessage() throws JMSException { - - return null; - } - - public MessageConsumer createConsumer(Destination arg0) throws JMSException { - - return null; - } - - public MessageConsumer createConsumer(Destination arg0, String arg1) throws JMSException { - - return null; - } - - public MessageConsumer createConsumer(Destination arg0, String arg1, boolean arg2) throws JMSException { - - return null; - } - - public MapMessage createMapMessage() throws JMSException { - - return null; - } - - public Message createMessage() throws JMSException { - - return null; - } - - public ObjectMessage createObjectMessage(Serializable arg0) throws JMSException { - - return null; - } - - public MessageProducer createProducer(Destination arg0) throws JMSException { - - return null; - } - - public Queue createQueue(String arg0) throws JMSException { - - return null; - } - - public StreamMessage createStreamMessage() throws JMSException { - - return null; - } - - public TemporaryQueue createTemporaryQueue() throws JMSException { - - return null; - } - - public TextMessage createTextMessage() throws JMSException { - - return null; - } - - public TextMessage createTextMessage(String arg0) throws JMSException { - - return null; - } - - public int getAcknowledgeMode() throws JMSException { - - return 0; - } - - public MessageListener getMessageListener() throws JMSException { - - return null; - } - - public boolean getTransacted() throws JMSException { - - return false; - } - - public void recover() throws JMSException { - - } - - public void rollback() throws JMSException { - - } - - public void run() { - - } - - public void setMessageListener(MessageListener arg0) throws JMSException { - - } - -} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -18,7 +18,7 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({ SyslogAppenderTest.class, DilutedSMTPAppenderTest.class, JMSQueueAppenderTest.class, JMSTopicAppenderTest.class, SMTPAppender_GreenTest.class, +@SuiteClasses({ SyslogAppenderTest.class, DilutedSMTPAppenderTest.class, SMTPAppender_GreenTest.class, SMTPAppender_SubethaSMTPTest.class, SocketReceiverTest.class, SSLSocketReceiverTest.class }) public class PackageTest { } \ No newline at end of file diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderMessageLossTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderMessageLossTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderMessageLossTest.java 2016-03-03 16:19:05.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderMessageLossTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -13,28 +13,28 @@ */ package ch.qos.logback.classic.net; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +import org.junit.Test; + import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.testUtil.RandomUtil; import ch.qos.logback.core.util.Duration; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; public class SocketAppenderMessageLossTest { int runLen = 100; Duration reconnectionDelay = new Duration(1000); static final int TIMEOUT = 3000; - - @Test(timeout = TIMEOUT) + + @Test // (timeout = TIMEOUT) public void synchronousSocketAppender() throws Exception { SocketAppender socketAppender = new SocketAppender(); @@ -90,9 +90,9 @@ listAppender.setContext(serverLoggerContext); listAppender.start(); - Logger serverLogger = serverLoggerContext.getLogger(getClass()); - serverLogger.setAdditive(false); - serverLogger.addAppender(listAppender); + Logger serverRootLogger = serverLoggerContext.getLogger(Logger.ROOT_LOGGER_NAME); + serverRootLogger.setAdditive(false); + serverRootLogger.addAppender(listAppender); LoggerContext loggerContext = new LoggerContext(); loggerContext.setName("clientLoggerContext"); @@ -120,9 +120,9 @@ } allMessagesReceivedLatch.await(); - - assertEquals(runLen, listAppender.list.size()); loggerContext.stop(); simpleSocketServer.close(); + + } } diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -40,12 +40,14 @@ Logger logger = lc.getLogger(ConverterTest.class); Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME); + String aMessage = "Some message"; + ILoggingEvent le; public PatternLayoutTest() { super(); Exception ex = new Exception("Bogus exception"); - le = makeLoggingEvent(ex); + le = makeLoggingEvent(aMessage, ex); } @Before @@ -53,16 +55,16 @@ pl.setContext(lc); } - ILoggingEvent makeLoggingEvent(Exception ex) { - return new LoggingEvent(ch.qos.logback.core.pattern.FormattingConverter.class.getName(), logger, Level.INFO, "Some message", ex, null); + ILoggingEvent makeLoggingEvent(String msg, Exception ex) { + return new LoggingEvent(ch.qos.logback.core.pattern.FormattingConverter.class.getName(), logger, Level.INFO, msg, ex, null); } - @Override + public ILoggingEvent getEventObject() { - return makeLoggingEvent(null); + return makeLoggingEvent("Some message", null); } - public PatternLayoutBase getPatternLayoutBase() { + public PatternLayoutBase getPatternLayoutBase() { return new PatternLayout(); } @@ -119,9 +121,8 @@ public void testWithParenthesis() { pl.setPattern("\\(%msg:%msg\\) %msg"); pl.start(); - le = makeLoggingEvent(null); + le = makeLoggingEvent(aMessage, null); String val = pl.doLayout(le); - // System.out.println("VAL == " + val); assertEquals("(Some message:Some message) Some message", val); } @@ -193,7 +194,7 @@ } @Test - public void somekeReplace() { + public void smokeReplace() { pl.setPattern("%replace(a1234b){'\\d{4}', 'XXXX'}"); pl.start(); StatusPrinter.print(lc); @@ -202,6 +203,18 @@ } @Test + public void replaceNewline() { + String pattern = "%replace(A\nB){'\n', '\n\t'}"; + String substPattern = OptionHelper.substVars(pattern, null, lc); + assertEquals(pattern, substPattern); + pl.setPattern(substPattern); + pl.start(); + StatusPrinter.print(lc); + String val = pl.doLayout(makeLoggingEvent("", null)); + assertEquals("A\n\tB", val); + } + + @Test public void replaceWithJoran() throws JoranException { configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "pattern/replace0.xml"); StatusPrinter.print(lc); @@ -214,4 +227,17 @@ assertEquals("And the number is XXXX, expiring on 12/2010", sla.strList.get(0)); } + @Test + public void replaceWithJoran_NEWLINE() throws JoranException { + lc.putProperty("TAB", "\t"); + configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "pattern/replaceNewline.xml"); + StatusPrinter.print(lc); + root.getAppender("LIST"); + String msg = "A\nC"; + logger.debug(msg); + StringListAppender sla = (StringListAppender) root.getAppender("LIST"); + assertNotNull(sla); + assertEquals(1, sla.strList.size()); + assertEquals("A\n\tC", sla.strList.get(0)); + } } diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/servlet/LogbackServletContainerInitializerTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/servlet/LogbackServletContainerInitializerTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/servlet/LogbackServletContainerInitializerTest.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/servlet/LogbackServletContainerInitializerTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,43 @@ +package ch.qos.logback.classic.servlet; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import ch.qos.logback.core.CoreConstants; + +import static org.mockito.Mockito.*; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; + +public class LogbackServletContainerInitializerTest { + + LogbackServletContainerInitializer lsci = new LogbackServletContainerInitializer(); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testOnStartup() throws ServletException { + ServletContext mockedServletContext = mock(ServletContext.class); + lsci.onStartup(null, mockedServletContext); + verify(mockedServletContext).addListener(any(LogbackServletContextListener.class)); + } + + @Test + public void noListenerShouldBeAddedWhenDisabled() throws ServletException { + ServletContext mockedServletContext = mock(ServletContext.class); + when(mockedServletContext.getInitParameter(CoreConstants.DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY)).thenReturn("true"); + lsci.onStartup(null, mockedServletContext); + verify(mockedServletContext, times(0)).addListener(any(LogbackServletContextListener.class)); + } + +} diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java 2016-02-25 21:15:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -34,11 +34,12 @@ import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.net.LoggingEventPreSerializationTransformer; +import ch.qos.logback.classic.net.server.HardenedLoggingEventInputStream; import ch.qos.logback.core.spi.PreSerializationTransformer; public class LoggingEventSerializationTest { - LoggerContext lc; + LoggerContext loggerContext; Logger logger; ByteArrayOutputStream bos; @@ -48,9 +49,9 @@ @Before public void setUp() throws Exception { - lc = new LoggerContext(); - lc.setName("testContext"); - logger = lc.getLogger(Logger.ROOT_LOGGER_NAME); + loggerContext = new LoggerContext(); + loggerContext.setName("testContext"); + logger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); // create the byte output stream bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); @@ -58,7 +59,7 @@ @After public void tearDown() throws Exception { - lc = null; + loggerContext = null; logger = null; oos.close(); } @@ -72,7 +73,7 @@ @Test public void context() throws Exception { - lc.putProperty("testKey", "testValue"); + loggerContext.putProperty("testKey", "testValue"); ILoggingEvent event = createLoggingEvent(); ILoggingEvent remoteEvent = writeAndRead(event); checkForEquality(event, remoteEvent); @@ -140,11 +141,17 @@ } @Test - public void _Throwable() throws Exception { - LoggingEvent event = createLoggingEvent(); + public void testWithThrowable() throws Exception { Throwable throwable = new Throwable("just testing"); - ThrowableProxy tp = new ThrowableProxy(throwable); - event.setThrowableProxy(tp); + LoggingEvent event = createLoggingEventWithThrowable(throwable); + ILoggingEvent remoteEvent = writeAndRead(event); + checkForEquality(event, remoteEvent); + } + + @Test + public void testWithCallerData() throws Exception { + LoggingEvent event = createLoggingEvent(); + event.getCallerData(); ILoggingEvent remoteEvent = writeAndRead(event); checkForEquality(event, remoteEvent); } @@ -187,6 +194,10 @@ return new LoggingEvent(this.getClass().getName(), logger, Level.DEBUG, "test message", null, null); } + private LoggingEvent createLoggingEventWithThrowable(Throwable t) { + return new LoggingEvent(this.getClass().getName(), logger, Level.DEBUG, "test message", t, null); + } + private void checkForEquality(ILoggingEvent original, ILoggingEvent afterSerialization) { assertEquals(original.getLevel(), afterSerialization.getLevel()); assertEquals(original.getFormattedMessage(), afterSerialization.getFormattedMessage()); @@ -203,8 +214,8 @@ Serializable ser = pst.transform(event); oos.writeObject(ser); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - inputStream = new ObjectInputStream(bis); - + inputStream = new HardenedLoggingEventInputStream(bis); + return (ILoggingEvent) inputStream.readObject(); } diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerAutoConfigTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerAutoConfigTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerAutoConfigTest.java 2016-02-25 21:15:39.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerAutoConfigTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -42,7 +42,7 @@ @After public void tearDown() throws Exception { System.clearProperty(ContextInitializer.CONFIG_FILE_PROPERTY); - System.clearProperty(CoreConstants.STATUS_LISTENER_CLASS); + System.clearProperty(CoreConstants.STATUS_LISTENER_CLASS_KEY); } @Test diff -Nru logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerTest.java logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerTest.java --- logback-1.1.9/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerTest.java 2016-02-25 21:15:39.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -59,7 +59,7 @@ @After public void tearDown() throws Exception { System.clearProperty(ContextInitializer.CONFIG_FILE_PROPERTY); - System.clearProperty(CoreConstants.STATUS_LISTENER_CLASS); + System.clearProperty(CoreConstants.STATUS_LISTENER_CLASS_KEY); MockConfigurator.context = null; } @@ -119,7 +119,7 @@ @Test public void autoStatusListener() throws JoranException { - System.setProperty(CoreConstants.STATUS_LISTENER_CLASS, TrivialStatusListener.class.getName()); + System.setProperty(CoreConstants.STATUS_LISTENER_CLASS_KEY, TrivialStatusListener.class.getName()); List statusListenerList = loggerContext.getStatusManager().getCopyOfStatusListenerList(); assertEquals(0, statusListenerList.size()); doAutoConfigFromSystemProperties(ClassicTestConstants.INPUT_PREFIX + "autoConfig.xml"); @@ -132,7 +132,7 @@ @Test public void autoOnConsoleStatusListener() throws JoranException { - System.setProperty(CoreConstants.STATUS_LISTENER_CLASS, CoreConstants.SYSOUT); + System.setProperty(CoreConstants.STATUS_LISTENER_CLASS_KEY, CoreConstants.SYSOUT); List sll = loggerContext.getStatusManager().getCopyOfStatusListenerList(); assertEquals(0, sll.size()); doAutoConfigFromSystemProperties(ClassicTestConstants.INPUT_PREFIX + "autoConfig.xml"); diff -Nru logback-1.1.9/logback-classic/src/test/java/org/slf4j/impl/InitializationOutputTest.java logback-1.2.3/logback-classic/src/test/java/org/slf4j/impl/InitializationOutputTest.java --- logback-1.1.9/logback-classic/src/test/java/org/slf4j/impl/InitializationOutputTest.java 2016-11-08 07:33:38.000000000 +0000 +++ logback-1.2.3/logback-classic/src/test/java/org/slf4j/impl/InitializationOutputTest.java 2017-03-30 02:48:10.000000000 +0000 @@ -56,13 +56,13 @@ public void tearDown() { System.setOut(original); System.clearProperty(ContextInitializer.CONFIG_FILE_PROPERTY); - System.clearProperty(CoreConstants.STATUS_LISTENER_CLASS); + System.clearProperty(CoreConstants.STATUS_LISTENER_CLASS_KEY); } @Test public void noOutputIfContextHasAStatusListener() { System.setProperty(ContextInitializer.CONFIG_FILE_PROPERTY, ClassicTestConstants.INPUT_PREFIX + "issue/logback292.xml"); - System.setProperty(CoreConstants.STATUS_LISTENER_CLASS, NopStatusListener.class.getName()); + System.setProperty(CoreConstants.STATUS_LISTENER_CLASS_KEY, NopStatusListener.class.getName()); StaticLoggerBinderFriend.reset(); assertEquals(0, tee.baos.size()); diff -Nru logback-1.1.9/logback-core/pom.xml logback-1.2.3/logback-core/pom.xml --- logback-1.1.9/logback-core/pom.xml 2017-01-20 18:37:25.000000000 +0000 +++ logback-1.2.3/logback-core/pom.xml 2017-04-01 03:15:20.000000000 +0000 @@ -1,3 +1,4 @@ + @@ -7,7 +8,7 @@ ch.qos.logback logback-parent - 1.1.9 + 1.2.3 logback-core @@ -25,7 +26,7 @@ org.fusesource.jansi jansi - true + true javax.mail @@ -34,20 +35,13 @@ true - org.apache.geronimo.specs - geronimo-jms_1.1_spec - compile - true - - org.mockito mockito-core - 1.9.5 test javax.servlet - servlet-api + javax.servlet-api compile true @@ -84,8 +78,7 @@ maven-jar-plugin - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + ${project.build.outputDirectory}/META-INF/MANIFEST.MF diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/AsyncAppenderBase.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/AsyncAppenderBase.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/AsyncAppenderBase.java 2016-03-03 11:51:31.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/AsyncAppenderBase.java 2017-03-30 02:48:10.000000000 +0000 @@ -15,6 +15,7 @@ import ch.qos.logback.core.spi.AppenderAttachable; import ch.qos.logback.core.spi.AppenderAttachableImpl; +import ch.qos.logback.core.util.InterruptUtil; import java.util.Iterator; import java.util.concurrent.ArrayBlockingQueue; @@ -123,7 +124,12 @@ // interrupt the worker thread so that it can terminate. Note that the interruption can be consumed // by sub-appenders worker.interrupt(); + + InterruptUtil interruptUtil = new InterruptUtil(context); + try { + interruptUtil.maskInterruptFlag(); + worker.join(maxFlushTime); // check to see if the thread ended and if not add a warning message @@ -135,10 +141,17 @@ } } catch (InterruptedException e) { - addError("Failed to join worker thread. " + blockingQueue.size() + " queued events may be discarded.", e); + int remaining = blockingQueue.size(); + addError("Failed to join worker thread. " + remaining + " queued events may be discarded.", e); + } finally { + interruptUtil.unmaskInterruptFlag(); } } + + + + @Override protected void append(E eventObject) { if (isQueueBelowDiscardingThreshold() && isDiscardable(eventObject)) { @@ -156,11 +169,23 @@ if (neverBlock) { blockingQueue.offer(eventObject); } else { - try { - blockingQueue.put(eventObject); - } catch (InterruptedException e) { - // Interruption of current thread when in doAppend method should not be consumed - // by AsyncAppender + putUninterruptibly(eventObject); + } + } + + private void putUninterruptibly(E eventObject) { + boolean interrupted = false; + try { + while (true) { + try { + blockingQueue.put(eventObject); + break; + } catch (InterruptedException e) { + interrupted = true; + } + } + } finally { + if (interrupted) { Thread.currentThread().interrupt(); } } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java 2017-01-20 11:08:01.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java 2017-03-30 02:48:10.000000000 +0000 @@ -14,6 +14,7 @@ package ch.qos.logback.core; import static ch.qos.logback.core.CoreConstants.CONTEXT_NAME_KEY; +import static ch.qos.logback.core.CoreConstants.HOSTNAME_KEY; import static ch.qos.logback.core.CoreConstants.FA_FILENAME_COLLISION_MAP; import static ch.qos.logback.core.CoreConstants.RFA_FILENAME_PATTERN_COLLISION_MAP; @@ -29,6 +30,7 @@ import ch.qos.logback.core.spi.LifeCycle; import ch.qos.logback.core.spi.LogbackLock; import ch.qos.logback.core.status.StatusManager; +import ch.qos.logback.core.util.ContextUtil; import ch.qos.logback.core.util.ExecutorServiceUtil; public class ContextBase implements Context, LifeCycle { @@ -81,7 +83,11 @@ } public void putProperty(String key, String val) { - this.propertyMap.put(key, val); + if (HOSTNAME_KEY.equalsIgnoreCase(key)) { + putHostnameProperty(val); + } else { + this.propertyMap.put(key, val); + } } protected void initCollisionMaps() { @@ -99,10 +105,31 @@ public String getProperty(String key) { if (CONTEXT_NAME_KEY.equals(key)) return getName(); + if (HOSTNAME_KEY.equalsIgnoreCase(key)) { + return lazyGetHostname(); + } return (String) this.propertyMap.get(key); } + private String lazyGetHostname() { + String hostname = (String) this.propertyMap.get(HOSTNAME_KEY); + if (hostname == null) { + hostname = new ContextUtil(this).safelyGetLocalHostName(); + putHostnameProperty(hostname); + } + return hostname; + } + + private void putHostnameProperty(String hostname) { + String existingHostname = (String) this.propertyMap.get(HOSTNAME_KEY); + if (existingHostname == null) { + this.propertyMap.put(CoreConstants.HOSTNAME_KEY, hostname); + } else { + + } + } + public Object getObject(String key) { return objectMap.get(key); } @@ -130,7 +157,7 @@ // We don't check "started" here, because the executor service uses // lazy initialization, rather than being created in the start method stopExecutorService(); - + started = false; } @@ -143,7 +170,7 @@ * shutdown hook */ public void reset() { - + removeShutdownHook(); getLifeCycleManager().reset(); propertyMap.clear(); @@ -248,7 +275,5 @@ public List> getScheduledFutures() { return new ArrayList>(scheduledFutures); } - - } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java 2017-01-20 18:21:19.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java 2017-03-30 02:48:10.000000000 +0000 @@ -16,7 +16,8 @@ public class CoreConstants { - final public static String STATUS_LISTENER_CLASS = "logback.statusListenerClass"; + final public static String DISABLE_SERVLET_CONTAINER_INITIALIZER_KEY = "logbackDisableServletContainerInitializer"; + final public static String STATUS_LISTENER_CLASS_KEY = "logback.statusListenerClass"; final public static String SYSOUT = "SYSOUT"; /** @@ -167,6 +168,8 @@ */ public static final String HOSTNAME_KEY = "HOSTNAME"; + public static final String UNKNOWN_LOCALHOST = "UNKNOWN_LOCALHOST"; + /** * The key under which the current context name is registered in the logger * context. diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java 2016-02-25 21:15:15.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java 2017-03-30 02:48:10.000000000 +0000 @@ -13,9 +13,6 @@ */ package ch.qos.logback.core.encoder; -import java.io.IOException; -import java.io.OutputStream; - import ch.qos.logback.core.CoreConstants; public class EchoEncoder extends EncoderBase { @@ -23,25 +20,22 @@ String fileHeader; String fileFooter; - public void doEncode(E event) throws IOException { + public byte[] encode(E event) { String val = event + CoreConstants.LINE_SEPARATOR; - outputStream.write(val.getBytes()); - // necessary if ResilientFileOutputStream is buffered - outputStream.flush(); + return val.getBytes(); } - public void close() throws IOException { + public byte[] footerBytes() { if (fileFooter == null) { - return; + return null; } - outputStream.write(fileFooter.getBytes()); + return fileFooter.getBytes(); } - public void init(OutputStream os) throws IOException { - super.init(os); + public byte[] headerBytes() { if (fileHeader == null) { - return; + return null; } - outputStream.write(fileHeader.getBytes()); + return fileHeader.getBytes(); } } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java 2016-02-25 21:15:16.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java 2017-03-30 02:48:10.000000000 +0000 @@ -13,21 +13,12 @@ */ package ch.qos.logback.core.encoder; -import java.io.IOException; -import java.io.OutputStream; - import ch.qos.logback.core.spi.ContextAwareBase; abstract public class EncoderBase extends ContextAwareBase implements Encoder { protected boolean started; - protected OutputStream outputStream; - - public void init(OutputStream os) throws IOException { - this.outputStream = os; - } - public boolean isStarted() { return started; } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/Encoder.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/Encoder.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/Encoder.java 2016-11-08 07:33:38.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/Encoder.java 2017-03-30 02:48:10.000000000 +0000 @@ -13,18 +13,11 @@ */ package ch.qos.logback.core.encoder; -import java.io.IOException; -import java.io.OutputStream; - import ch.qos.logback.core.spi.ContextAware; import ch.qos.logback.core.spi.LifeCycle; /** * Encoders are responsible for transform an incoming event into a byte array - * *and* writing out the byte array onto the appropriate {@link OutputStream}. - * Thus, encoders have total control of what and when gets written to the - * {@link OutputStream} maintained by the owning appender. - * * * @author Ceki Gülcü * @author Joern Huxhorn @@ -37,32 +30,25 @@ public interface Encoder extends ContextAware, LifeCycle { /** - * This method is called when the owning appender starts or whenever output - * needs to be directed to a new OutputStream, for instance as a result of a - * rollover. Implementing encoders should at the very least remember the - * OutputStream passed as argument and use it in future operations. + * Get header bytes. This method is typically called upon opening of + * an output stream. * - * @param os - * @throws IOException + * @return header bytes. Null values are allowed. */ - void init(OutputStream os) throws IOException; + byte[] headerBytes(); /** - * Encode and write an event to the appropriate {@link OutputStream}. - * Implementations are free to differ writing out of the encoded event and - * instead write in batches. - * + * Encode an event as bytes. + * * @param event - * @throws IOException */ - void doEncode(E event) throws IOException; - + byte[] encode(E event); + /** - * This method is called prior to the closing of the underling - * {@link OutputStream}. Implementations MUST not close the underlying - * {@link OutputStream} which is the responsibility of the owning appender. + * Get footer bytes. This method is typically called prior to the closing + * of the stream where events are written. * - * @throws IOException + * @return footer bytes. Null values are allowed. */ - void close() throws IOException; + byte[] footerBytes(); } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java 2016-02-25 21:15:17.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,156 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.encoder; - -import static ch.qos.logback.core.CoreConstants.BYTES_PER_INT; -import static ch.qos.logback.core.encoder.ObjectStreamEncoder.START_PEBBLE; -import static ch.qos.logback.core.encoder.ObjectStreamEncoder.STOP_PEBBLE; - -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.util.ArrayList; -import java.util.List; - -/** - * Restitute the contents of an input stream as java objects. - * - * @author Ceki Gülcü - * - * @param - */ -public class EventObjectInputStream extends InputStream { - - NonClosableInputStream ncis; - List buffer = new ArrayList(); - - int index = 0; - - EventObjectInputStream(InputStream is) throws IOException { - this.ncis = new NonClosableInputStream(is); - } - - @Override - public int read() throws IOException { - throw new UnsupportedOperationException("Only the readEvent method is supported."); - } - - /** - * Returns the number of bytes available - */ - public int available() throws IOException { - return ncis.available(); - } - - public E readEvent() throws IOException { - - E event = getFromBuffer(); - if (event != null) { - return event; - } - - internalReset(); - int count = readHeader(); - if (count == -1) { - return null; - } - readPayload(count); - readFooter(count); - return getFromBuffer(); - } - - private void internalReset() { - index = 0; - buffer.clear(); - } - - E getFromBuffer() { - if (index >= buffer.size()) { - return null; - } - return buffer.get(this.index++); - } - - int readHeader() throws IOException { - byte[] headerBA = new byte[4 * BYTES_PER_INT]; - // System.out.println("available="+ncis.available()); - int bytesRead = ncis.read(headerBA); - if (bytesRead == -1) { - return -1; - } - // System.out.println("**bytesRead="+bytesRead); - - // System.out.println(ByteArrayUtil.toHexString(headerBA)); - - int offset = 0; - int startPebble = ByteArrayUtil.readInt(headerBA, offset); - if (startPebble != START_PEBBLE) { - throw new IllegalStateException("Does not look like data created by ObjectStreamEncoder"); - } - offset += BYTES_PER_INT; - int count = ByteArrayUtil.readInt(headerBA, offset); - offset += BYTES_PER_INT; - int endPointer = ByteArrayUtil.readInt(headerBA, offset); - offset += BYTES_PER_INT; - int checksum = ByteArrayUtil.readInt(headerBA, offset); - if (checksum != (START_PEBBLE ^ count)) { - throw new IllegalStateException("Invalid checksum"); - } - return count; - } - - @SuppressWarnings("unchecked") - E readEvents(ObjectInputStream ois) throws IOException { - E e = null; - try { - e = (E) ois.readObject(); - buffer.add(e); - } catch (ClassNotFoundException e1) { - // FIXME Auto-generated catch block - e1.printStackTrace(); - } - return e; - } - - void readFooter(int count) throws IOException { - byte[] headerBA = new byte[2 * BYTES_PER_INT]; - ncis.read(headerBA); - - int offset = 0; - int stopPebble = ByteArrayUtil.readInt(headerBA, offset); - if (stopPebble != STOP_PEBBLE) { - throw new IllegalStateException("Looks like a corrupt stream"); - } - offset += BYTES_PER_INT; - int checksum = ByteArrayUtil.readInt(headerBA, offset); - if (checksum != (STOP_PEBBLE ^ count)) { - throw new IllegalStateException("Invalid checksum"); - } - } - - void readPayload(int count) throws IOException { - List eventList = new ArrayList(count); - ObjectInputStream ois = new ObjectInputStream(ncis); - for (int i = 0; i < count; i++) { - E e = (E) readEvents(ois); - eventList.add(e); - } - ois.close(); - } - - public void close() throws IOException { - ncis.realClose(); - } - -} diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java 2016-02-25 21:15:15.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java 2017-04-01 00:34:00.000000000 +0000 @@ -13,13 +13,12 @@ */ package ch.qos.logback.core.encoder; -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; +import ch.qos.logback.core.Appender; import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.Layout; +import ch.qos.logback.core.OutputStreamAppender; public class LayoutWrappingEncoder extends EncoderBase { @@ -34,22 +33,8 @@ */ private Charset charset; - private boolean immediateFlush = true; - - /** - * Sets the immediateFlush option. The default value for immediateFlush is 'true'. If set to true, - * the doEncode() method will immediately flush the underlying OutputStream. Although immediate flushing - * is safer, it also significantly degrades logging throughput. - * - * @since 1.0.3 - */ - public void setImmediateFlush(boolean immediateFlush) { - this.immediateFlush = immediateFlush; - } - - public boolean isImmediateFlush() { - return immediateFlush; - } + Appender parent; + Boolean immediateFlush = null; public Layout getLayout() { return layout; @@ -77,60 +62,58 @@ this.charset = charset; } - public void init(OutputStream os) throws IOException { - super.init(os); - writeHeader(); - } - - void writeHeader() throws IOException { - if (layout != null && (outputStream != null)) { - StringBuilder sb = new StringBuilder(); - appendIfNotNull(sb, layout.getFileHeader()); - appendIfNotNull(sb, layout.getPresentationHeader()); - if (sb.length() > 0) { - sb.append(CoreConstants.LINE_SEPARATOR); - // If at least one of file header or presentation header were not - // null, then append a line separator. - // This should be useful in most cases and should not hurt. - outputStream.write(convertToBytes(sb.toString())); - outputStream.flush(); - } - } + /** + * Sets the immediateFlush option. The default value for immediateFlush is 'true'. If set to true, + * the doEncode() method will immediately flush the underlying OutputStream. Although immediate flushing + * is safer, it also significantly degrades logging throughput. + * + * @since 1.0.3 + */ + public void setImmediateFlush(boolean immediateFlush) { + addWarn("As of version 1.2.0 \"immediateFlush\" property should be set within the enclosing Appender."); + addWarn("Please move \"immediateFlush\" property into the enclosing appender."); + this.immediateFlush = immediateFlush; } - public void close() throws IOException { - writeFooter(); + @Override + public byte[] headerBytes() { + if (layout == null) + return null; + + StringBuilder sb = new StringBuilder(); + appendIfNotNull(sb, layout.getFileHeader()); + appendIfNotNull(sb, layout.getPresentationHeader()); + if (sb.length() > 0) { + // If at least one of file header or presentation header were not + // null, then append a line separator. + // This should be useful in most cases and should not hurt. + sb.append(CoreConstants.LINE_SEPARATOR); + } + return convertToBytes(sb.toString()); } - void writeFooter() throws IOException { - if (layout != null && outputStream != null) { - StringBuilder sb = new StringBuilder(); - appendIfNotNull(sb, layout.getPresentationFooter()); - appendIfNotNull(sb, layout.getFileFooter()); - if (sb.length() > 0) { - outputStream.write(convertToBytes(sb.toString())); - outputStream.flush(); - } - } + @Override + public byte[] footerBytes() { + if (layout == null) + return null; + + StringBuilder sb = new StringBuilder(); + appendIfNotNull(sb, layout.getPresentationFooter()); + appendIfNotNull(sb, layout.getFileFooter()); + return convertToBytes(sb.toString()); } private byte[] convertToBytes(String s) { if (charset == null) { return s.getBytes(); } else { - try { - return s.getBytes(charset.name()); - } catch (UnsupportedEncodingException e) { - throw new IllegalStateException("An existing charset cannot possibly be unsupported."); - } + return s.getBytes(charset); } } - public void doEncode(E event) throws IOException { + public byte[] encode(E event) { String txt = layout.doLayout(event); - outputStream.write(convertToBytes(txt)); - if (immediateFlush) - outputStream.flush(); + return convertToBytes(txt); } public boolean isStarted() { @@ -138,17 +121,21 @@ } public void start() { + if (immediateFlush != null) { + if (parent instanceof OutputStreamAppender) { + addWarn("Setting the \"immediateFlush\" property of the enclosing appender to " + immediateFlush); + @SuppressWarnings("unchecked") + OutputStreamAppender parentOutputStreamAppender = (OutputStreamAppender) parent; + parentOutputStreamAppender.setImmediateFlush(immediateFlush); + } else { + addError("Could not set the \"immediateFlush\" property of the enclosing appender."); + } + } started = true; } public void stop() { started = false; - if (outputStream != null) { - try { - outputStream.flush(); - } catch (IOException e) { - } - } } private void appendIfNotNull(StringBuilder sb, String s) { @@ -157,4 +144,13 @@ } } + /** + * This method allows RollingPolicy implementations to be aware of their + * containing appender. + * + * @param appender + */ + public void setParent(Appender parent) { + this.parent = parent; + } } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java 2016-02-25 21:15:19.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.encoder; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; - -import ch.qos.logback.core.CoreConstants; - -/** - * Write out events as java objects. - * - * @author Ceki Gülcü - * - * @param - */ -public class ObjectStreamEncoder extends EncoderBase { - - static public final int START_PEBBLE = 1853421169; - static public final int STOP_PEBBLE = 640373619; - - private int MAX_BUFFER_SIZE = 100; - - List bufferList = new ArrayList(MAX_BUFFER_SIZE); - - public void doEncode(E event) throws IOException { - bufferList.add(event); - if (bufferList.size() == MAX_BUFFER_SIZE) { - writeBuffer(); - } - } - - void writeHeader(ByteArrayOutputStream baos, int bufferSize) { - ByteArrayUtil.writeInt(baos, START_PEBBLE); - ByteArrayUtil.writeInt(baos, bufferSize); - ByteArrayUtil.writeInt(baos, 0); - ByteArrayUtil.writeInt(baos, START_PEBBLE ^ bufferSize); - } - - void writeFooter(ByteArrayOutputStream baos, int bufferSize) { - ByteArrayUtil.writeInt(baos, STOP_PEBBLE); - ByteArrayUtil.writeInt(baos, STOP_PEBBLE ^ bufferSize); - } - - void writeBuffer() throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(10000); - - int size = bufferList.size(); - writeHeader(baos, size); - ObjectOutputStream oos = new ObjectOutputStream(baos); - for (E e : bufferList) { - oos.writeObject(e); - } - bufferList.clear(); - oos.flush(); - - writeFooter(baos, size); - - byte[] byteArray = baos.toByteArray(); - oos.close(); - writeEndPosition(byteArray); - outputStream.write(byteArray); - - } - - void writeEndPosition(byte[] byteArray) { - int offset = 2 * CoreConstants.BYTES_PER_INT; - ByteArrayUtil.writeInt(byteArray, offset, byteArray.length - offset); - } - - @Override - public void init(OutputStream os) throws IOException { - super.init(os); - bufferList.clear(); - } - - public void close() throws IOException { - writeBuffer(); - } -} diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java 2017-01-20 17:53:07.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java 2017-03-30 02:48:10.000000000 +0000 @@ -25,6 +25,7 @@ import ch.qos.logback.core.recovery.ResilientFileOutputStream; import ch.qos.logback.core.util.ContextUtil; +import ch.qos.logback.core.util.FileSize; import ch.qos.logback.core.util.FileUtil; /** @@ -37,6 +38,8 @@ */ public class FileAppender extends OutputStreamAppender { + public static final long DEFAULT_BUFFER_SIZE = 8192; + static protected String COLLISION_WITH_EARLIER_APPENDER_URL = CODES_URL + "#earlier_fa_collision"; /** @@ -53,6 +56,8 @@ private boolean prudent = false; + private FileSize bufferSize = new FileSize(DEFAULT_BUFFER_SIZE); + /** * The File property takes a string value which should be the name of * the file to append to. @@ -196,7 +201,7 @@ addError("Failed to create parent directories for [" + file.getAbsolutePath() + "]"); } - ResilientFileOutputStream resilientFos = new ResilientFileOutputStream(file, append); + ResilientFileOutputStream resilientFos = new ResilientFileOutputStream(file, append, bufferSize.getSize()); resilientFos.setContext(context); setOutputStream(resilientFos); } finally { @@ -226,6 +231,11 @@ public void setAppend(boolean append) { this.append = append; } + + public void setBufferSize(FileSize bufferSize) { + addInfo("Setting bufferSize to ["+bufferSize.toString()+"]"); + this.bufferSize = bufferSize; + } private void safeWrite(E event) throws IOException { ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) getOutputStream(); diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java 2016-03-29 14:04:46.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java 2017-03-30 02:48:10.000000000 +0000 @@ -21,7 +21,7 @@ public class ParamAction extends Action { static String NO_NAME = "No name attribute in element"; - static String NO_VALUE = "No name attribute in element"; + static String NO_VALUE = "No value attribute in element"; boolean inError = false; private final BeanDescriptionCache beanDescriptionCache; diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java 2016-11-25 19:36:01.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java 2017-03-30 02:48:10.000000000 +0000 @@ -50,7 +50,7 @@ urlConnection.setUseCaches(false); in = urlConnection.getInputStream(); - doConfigure(in); + doConfigure(in, url.toExternalForm()); } catch (IOException ioe) { String errMsg = "Could not open URL [" + url + "]."; addError(errMsg, ioe); @@ -75,9 +75,10 @@ public final void doConfigure(File file) throws JoranException { FileInputStream fis = null; try { - informContextOfURLUsedForConfiguration(getContext(), file.toURI().toURL()); + URL url = file.toURI().toURL(); + informContextOfURLUsedForConfiguration(getContext(), url); fis = new FileInputStream(file); - doConfigure(fis); + doConfigure(fis, url.toExternalForm()); } catch (IOException ioe) { String errMsg = "Could not open [" + file.getPath() + "]."; addError(errMsg, ioe); @@ -103,6 +104,12 @@ doConfigure(new InputSource(inputStream)); } + public final void doConfigure(InputStream inputStream, String systemId) throws JoranException { + InputSource inputSource = new InputSource(inputStream); + inputSource.setSystemId(systemId); + doConfigure(inputSource); + } + protected BeanDescriptionCache getBeanDescriptionCache() { if (beanDescriptionCache == null) { beanDescriptionCache = new BeanDescriptionCache(getContext()); diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/net/HardenedObjectInputStream.java 2017-03-30 02:48:10.000000000 +0000 @@ -0,0 +1,71 @@ +package ch.qos.logback.core.net; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InvalidClassException; +import java.io.ObjectInputStream; +import java.io.ObjectStreamClass; +import java.util.ArrayList; +import java.util.List; + +/** + * HardenedObjectInputStream restricts the set of classes that can be deserialized to a set of + * explicitly whitelisted classes. This prevents certain type of attacks from being successful. + * + *

      It is assumed that classes in the "java.lang" and "java.util" packages are + * always authorized.

      + * + * @author Ceki Gülcü + * @since 1.2.0 + */ +public class HardenedObjectInputStream extends ObjectInputStream { + + final List whitelistedClassNames; + final static String[] JAVA_PACKAGES = new String[] { "java.lang", "java.util" }; + + public HardenedObjectInputStream(InputStream in, String[] whilelist) throws IOException { + super(in); + + this.whitelistedClassNames = new ArrayList(); + if (whilelist != null) { + for (int i = 0; i < whilelist.length; i++) { + this.whitelistedClassNames.add(whilelist[i]); + } + } + } + + public HardenedObjectInputStream(InputStream in, List whitelist) throws IOException { + super(in); + + this.whitelistedClassNames = new ArrayList(); + this.whitelistedClassNames.addAll(whitelist); + } + + @Override + protected Class resolveClass(ObjectStreamClass anObjectStreamClass) throws IOException, ClassNotFoundException { + + String incomingClassName = anObjectStreamClass.getName(); + + if (!isWhitelisted(incomingClassName)) { + throw new InvalidClassException("Unauthorized deserialization attempt", anObjectStreamClass.getName()); + } + + return super.resolveClass(anObjectStreamClass); + } + + private boolean isWhitelisted(String incomingClassName) { + for (int i = 0; i < JAVA_PACKAGES.length; i++) { + if (incomingClassName.startsWith(JAVA_PACKAGES[i])) + return true; + } + for (String whiteListed : whitelistedClassNames) { + if (incomingClassName.equals(whiteListed)) + return true; + } + return false; + } + + protected void addToWhitelist(List additionalAuthorizedClasses) { + whitelistedClassNames.addAll(additionalAuthorizedClasses); + } +} diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/net/JMSAppenderBase.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/net/JMSAppenderBase.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/net/JMSAppenderBase.java 2016-02-25 21:15:16.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/net/JMSAppenderBase.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.net; - -import java.util.Hashtable; -import java.util.Properties; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NameNotFoundException; -import javax.naming.NamingException; - -import ch.qos.logback.core.AppenderBase; - -/** - * This class serves as a base class for - * JMSTopicAppender and JMSQueueAppender - * - * For more information about this appender, please refer to: - * http://logback.qos.ch/manual/appenders.html#JMSAppenderBase - * - * @author Ceki Gülcü - * @author Sébastien Pennec - */ -public abstract class JMSAppenderBase extends AppenderBase { - - protected String securityPrincipalName; - protected String securityCredentials; - protected String initialContextFactoryName; - protected String urlPkgPrefixes; - protected String providerURL; - protected String userName; - protected String password; - - protected Object lookup(Context ctx, String name) throws NamingException { - try { - return ctx.lookup(name); - } catch (NameNotFoundException e) { - addError("Could not find name [" + name + "]."); - throw e; - } - } - - public Context buildJNDIContext() throws NamingException { - Context jndi = null; - - // addInfo("Getting initial context."); - if (initialContextFactoryName != null) { - Properties env = buildEnvProperties(); - jndi = new InitialContext(env); - } else { - jndi = new InitialContext(); - } - return jndi; - } - - public Properties buildEnvProperties() { - Properties env = new Properties(); - env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactoryName); - if (providerURL != null) { - env.put(Context.PROVIDER_URL, providerURL); - } else { - addWarn("You have set InitialContextFactoryName option but not the " + "ProviderURL. This is likely to cause problems."); - } - if (urlPkgPrefixes != null) { - env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes); - } - - if (securityPrincipalName != null) { - env.put(Context.SECURITY_PRINCIPAL, securityPrincipalName); - if (securityCredentials != null) { - env.put(Context.SECURITY_CREDENTIALS, securityCredentials); - } else { - addWarn("You have set SecurityPrincipalName option but not the " + "SecurityCredentials. This is likely to cause problems."); - } - } - return env; - } - - /** - * Returns the value of the InitialContextFactoryName option. See - * {@link #setInitialContextFactoryName} for more details on the meaning of - * this option. - */ - public String getInitialContextFactoryName() { - return initialContextFactoryName; - } - - /** - * Setting the InitialContextFactoryName method will cause this - * JMSAppender instance to use the {@link - * InitialContext#InitialContext(Hashtable)} method instead of the no-argument - * constructor. If you set this option, you should also at least set the - * ProviderURL option. - * - *

      - * See also {@link #setProviderURL(String)}. - */ - public void setInitialContextFactoryName(String initialContextFactoryName) { - this.initialContextFactoryName = initialContextFactoryName; - } - - public String getProviderURL() { - return providerURL; - } - - public void setProviderURL(String providerURL) { - this.providerURL = providerURL; - } - - public String getURLPkgPrefixes() { - return urlPkgPrefixes; - } - - public void setURLPkgPrefixes(String urlPkgPrefixes) { - this.urlPkgPrefixes = urlPkgPrefixes; - } - - public String getSecurityCredentials() { - return securityCredentials; - } - - public void setSecurityCredentials(String securityCredentials) { - this.securityCredentials = securityCredentials; - } - - public String getSecurityPrincipalName() { - return securityPrincipalName; - } - - public void setSecurityPrincipalName(String securityPrincipalName) { - this.securityPrincipalName = securityPrincipalName; - } - - public String getUserName() { - return userName; - } - - /** - * The user name to use when {@link - * javax.jms.TopicConnectionFactory#createTopicConnection(String, String)} - * creating a topic session}. If you set this option, you should also set the - * Password option. See {@link #setPassword(String)}. - */ - public void setUserName(String userName) { - this.userName = userName; - } - - public String getPassword() { - return password; - } - - /** - * The password to use when creating a topic session. - */ - public void setPassword(String password) { - this.password = password; - } - -} diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java 2016-02-25 21:15:20.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java 2017-03-30 02:48:10.000000000 +0000 @@ -44,18 +44,20 @@ /** * All synchronization in this class is done via the lock object. */ - protected final ReentrantLock lock = new ReentrantLock(true); + protected final ReentrantLock lock = new ReentrantLock(false); /** * This is the {@link OutputStream outputStream} where output will be written. */ private OutputStream outputStream; + boolean immediateFlush = true; + /** - * The underlying output stream used by this appender. - * - * @return - */ + * The underlying output stream used by this appender. + * + * @return + */ public OutputStream getOutputStream() { return outputStream; } @@ -133,21 +135,11 @@ } } - void encoderInit() { - if (encoder != null && this.outputStream != null) { - try { - encoder.init(outputStream); - } catch (IOException ioe) { - this.started = false; - addStatus(new ErrorStatus("Failed to initialize encoder for appender named [" + name + "].", this, ioe)); - } - } - } - void encoderClose() { if (encoder != null && this.outputStream != null) { try { - encoder.close(); + byte[] footer = encoder.footerBytes(); + writeBytes(footer); } catch (IOException ioe) { this.started = false; addStatus(new ErrorStatus("Failed to write footer for appender named [" + name + "].", this, ioe)); @@ -170,7 +162,6 @@ try { // close any previously opened output stream closeOutputStream(); - this.outputStream = outputStream; if (encoder == null) { addWarn("Encoder has not been set. Cannot invoke its init method."); @@ -183,8 +174,35 @@ } } + void encoderInit() { + if (encoder != null && this.outputStream != null) { + try { + byte[] header = encoder.headerBytes(); + writeBytes(header); + } catch (IOException ioe) { + this.started = false; + addStatus(new ErrorStatus("Failed to initialize encoder for appender named [" + name + "].", this, ioe)); + } + } + } protected void writeOut(E event) throws IOException { - this.encoder.doEncode(event); + byte[] byteArray = this.encoder.encode(event); + writeBytes(byteArray); + } + + private void writeBytes(byte[] byteArray) throws IOException { + if(byteArray == null || byteArray.length == 0) + return; + + lock.lock(); + try { + this.outputStream.write(byteArray); + if (immediateFlush) { + this.outputStream.flush(); + } + } finally { + lock.unlock(); + } } /** @@ -207,12 +225,11 @@ // the synchronization prevents the OutputStream from being closed while we // are writing. It also prevents multiple threads from entering the same // converter. Converters assume that they are in a synchronized block. - lock.lock(); - try { - writeOut(event); - } finally { - lock.unlock(); - } + // lock.lock(); + + byte[] byteArray = this.encoder.encode(event); + writeBytes(byteArray); + } catch (IOException ioe) { // as soon as an exception occurs, move to non-started state // and add a single ErrorStatus to the SM. @@ -229,4 +246,12 @@ this.encoder = encoder; } + public boolean isImmediateFlush() { + return immediateFlush; + } + + public void setImmediateFlush(boolean immediateFlush) { + this.immediateFlush = immediateFlush; + } + } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java 2016-02-25 21:15:17.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java 2017-03-30 02:48:11.000000000 +0000 @@ -13,6 +13,9 @@ */ package ch.qos.logback.core.pattern; +import java.util.HashMap; +import java.util.Map; + import ch.qos.logback.core.Context; import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.LayoutBase; @@ -22,18 +25,16 @@ import ch.qos.logback.core.status.ErrorStatus; import ch.qos.logback.core.status.StatusManager; -import java.util.HashMap; -import java.util.Map; - abstract public class PatternLayoutBase extends LayoutBase { + static final int INTIAL_STRING_BUILDER_SIZE = 256; Converter head; String pattern; protected PostCompileProcessor postCompileProcessor; - + Map instanceConverterMap = new HashMap(); protected boolean outputPatternAsHeader = false; - + /** * Concrete implementations of this class are responsible for elaborating the * mapping between pattern words and converters. @@ -108,13 +109,13 @@ } protected String writeLoopOnConverters(E event) { - StringBuilder buf = new StringBuilder(128); + StringBuilder strBuilder = new StringBuilder(INTIAL_STRING_BUILDER_SIZE); Converter c = head; while (c != null) { - c.write(buf, event); + c.write(strBuilder, event); c = c.getNext(); } - return buf.toString(); + return strBuilder.toString(); } public String getPattern() { diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java 2016-02-25 21:15:18.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java 2017-03-30 02:48:11.000000000 +0000 @@ -21,10 +21,10 @@ private File file; private FileOutputStream fos; - public ResilientFileOutputStream(File file, boolean append) throws FileNotFoundException { + public ResilientFileOutputStream(File file, boolean append, long bufferSize) throws FileNotFoundException { this.file = file; fos = new FileOutputStream(file, append); - this.os = new BufferedOutputStream(fos); + this.os = new BufferedOutputStream(fos, (int) bufferSize); this.presumedClean = true; } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RollingCalendar.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RollingCalendar.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RollingCalendar.java 2016-03-27 11:10:49.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RollingCalendar.java 2017-03-30 02:48:11.000000000 +0000 @@ -14,6 +14,9 @@ package ch.qos.logback.core.rolling.helper; import static ch.qos.logback.core.CoreConstants.MILLIS_IN_ONE_HOUR; +import static ch.qos.logback.core.CoreConstants.MILLIS_IN_ONE_MINUTE; +import static ch.qos.logback.core.CoreConstants.MILLIS_IN_ONE_SECOND; +import static ch.qos.logback.core.CoreConstants.MILLIS_IN_ONE_WEEK; import static ch.qos.logback.core.CoreConstants.MILLIS_IN_ONE_DAY; import java.text.SimpleDateFormat; @@ -23,7 +26,6 @@ import java.util.Locale; import java.util.TimeZone; -import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.spi.ContextAwareBase; /** @@ -71,7 +73,6 @@ public PeriodicityType computePeriodicityType() { GregorianCalendar calendar = new GregorianCalendar(GMT_TIMEZONE, Locale.getDefault()); - // set sate to 1970-01-01 00:00:00 GMT Date epoch = new Date(0); @@ -180,25 +181,26 @@ if (start > end) throw new IllegalArgumentException("Start cannot come before end"); - Date startFloored = getsStartOfCurrentPeriod(start); - Date endFloored = getsStartOfCurrentPeriod(end); - - long diff = endFloored.getTime() - startFloored.getTime(); - + long startFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(start, getTimeZone()); + long endFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(end, getTimeZone()); + + long diff = endFloored - startFloored; + switch (periodicityType) { case TOP_OF_MILLISECOND: return diff; case TOP_OF_SECOND: - return diff / CoreConstants.MILLIS_IN_ONE_SECOND; + return diff / MILLIS_IN_ONE_SECOND; case TOP_OF_MINUTE: - return diff / CoreConstants.MILLIS_IN_ONE_MINUTE; + return diff / MILLIS_IN_ONE_MINUTE; case TOP_OF_HOUR: - return (int) diff / CoreConstants.MILLIS_IN_ONE_HOUR; + + return (int) diff / MILLIS_IN_ONE_HOUR; case TOP_OF_DAY: - return diff / CoreConstants.MILLIS_IN_ONE_DAY; + return diff / MILLIS_IN_ONE_DAY; case TOP_OF_WEEK: - return diff / CoreConstants.MILLIS_IN_ONE_WEEK; + return diff / MILLIS_IN_ONE_WEEK; case TOP_OF_MONTH: return diffInMonths(start, end); default: @@ -263,7 +265,7 @@ cal.set(Calendar.MILLISECOND, 0); cal.add(Calendar.WEEK_OF_YEAR, numPeriods); break; - + case TOP_OF_MONTH: cal.set(Calendar.DATE, 1); cal.set(Calendar.HOUR_OF_DAY, 0); @@ -287,10 +289,20 @@ public Date getNextTriggeringDate(Date now) { return getEndOfNextNthPeriod(now, 1); } - - public Date getsStartOfCurrentPeriod(long now) { - Calendar aCal = Calendar.getInstance(getTimeZone()); - aCal.setTimeInMillis(now); - return getEndOfNextNthPeriod(aCal.getTime(), 0); + + public long getStartOfCurrentPeriodWithGMTOffsetCorrection(long now, TimeZone timezone) { + Date toppedDate; + + // there is a bug in Calendar which prevents it from + // computing the correct DST_OFFSET when the time changes + { + Calendar aCal = Calendar.getInstance(timezone); + aCal.setTimeInMillis(now); + toppedDate = getEndOfNextNthPeriod(aCal.getTime(), 0); + } + Calendar secondCalendar = Calendar.getInstance(timezone); + secondCalendar.setTimeInMillis(toppedDate.getTime()); + long gmtOffset = secondCalendar.get(Calendar.ZONE_OFFSET) + secondCalendar.get(Calendar.DST_OFFSET); + return toppedDate.getTime() + gmtOffset; } } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TimeBasedArchiveRemover.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TimeBasedArchiveRemover.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TimeBasedArchiveRemover.java 2016-05-13 22:08:06.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/TimeBasedArchiveRemover.java 2017-03-30 02:48:11.000000000 +0000 @@ -31,7 +31,7 @@ public class TimeBasedArchiveRemover extends ContextAwareBase implements ArchiveRemover { static protected final long UNINITIALIZED = -1; - // aim for 64 days, except in case of hourly rollover + // aim for 32 days, except in case of hourly rollover static protected final long INACTIVITY_TOLERANCE_IN_MILLIS = 32L * (long) CoreConstants.MILLIS_IN_ONE_DAY; static final int MAX_VALUE_FOR_INACTIVITY_PERIODS = 14 * 24; // 14 days in case of hourly rollover @@ -48,9 +48,11 @@ this.parentClean = computeParentCleaningFlag(fileNamePattern); } + int callCount = 0; public void clean(Date now) { + long nowInMillis = now.getTime(); - // for a live appender periodsElapsed is usually one + // for a live appender periodsElapsed is expected to be 1 int periodsElapsed = computeElapsedPeriodsSinceLastClean(nowInMillis); lastHeartBeat = nowInMillis; if (periodsElapsed > 1) { @@ -93,8 +95,8 @@ } void capTotalSize(Date now) { - int totalSize = 0; - int totalRemoved = 0; + long totalSize = 0; + long totalRemoved = 0; for (int offset = 0; offset < maxHistory; offset++) { Date date = rc.getEndOfNextNthPeriod(now, -offset); File[] matchingFileArray = getFilesInPeriod(date); @@ -143,7 +145,7 @@ periodsElapsed = Math.min(periodsElapsed, MAX_VALUE_FOR_INACTIVITY_PERIODS); } else { periodsElapsed = rc.periodBarriersCrossed(lastHeartBeat, nowInMillis); - // periodsElapsed of zero is possible for Size and time based policies + // periodsElapsed of zero is possible for size and time based policies } return (int) periodsElapsed; } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java 2016-12-09 16:26:37.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java 2017-03-30 02:48:11.000000000 +0000 @@ -179,7 +179,7 @@ if (archiveRemover != null) { Date now = new Date(timeBasedFileNamingAndTriggeringPolicy.getCurrentTime()); - cleanUpFuture = archiveRemover.cleanAsynchronously(now); + this.cleanUpFuture = archiveRemover.cleanAsynchronously(now); } } @@ -261,6 +261,7 @@ } public void setTotalSizeCap(FileSize totalSizeCap) { + addInfo("setting totalSizeCap to "+totalSizeCap.toString()); this.totalSizeCap = totalSizeCap; } } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java 2016-02-25 21:15:19.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java 2017-03-30 02:48:11.000000000 +0000 @@ -14,9 +14,9 @@ package ch.qos.logback.core.spi; import java.util.Iterator; -import java.util.concurrent.CopyOnWriteArrayList; import ch.qos.logback.core.Appender; +import ch.qos.logback.core.util.COWArrayList; /** * A ReentrantReadWriteLock based implementation of the @@ -26,7 +26,8 @@ */ public class AppenderAttachableImpl implements AppenderAttachable { - final private CopyOnWriteArrayList> appenderList = new CopyOnWriteArrayList>(); + @SuppressWarnings("unchecked") + final private COWArrayList> appenderList = new COWArrayList>(new Appender[0]); /** * Attach an appender. If the appender is already in the list in won't be @@ -44,8 +45,10 @@ */ public int appendLoopOnAppenders(E e) { int size = 0; - for (Appender appender : appenderList) { - appender.doAppend(e); + final Appender[] appenderArray = appenderList.asTypedArray(); + final int len = appenderArray.length; + for (int i = 0; i < len; i++) { + appenderArray[i].doAppend(e); size++; } return size; diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java 2016-02-25 21:15:20.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java 2017-03-30 02:48:11.000000000 +0000 @@ -15,9 +15,9 @@ import java.util.ArrayList; import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.util.COWArrayList; /** * Implementation of FilterAttachable. @@ -26,7 +26,8 @@ */ final public class FilterAttachableImpl implements FilterAttachable { - CopyOnWriteArrayList> filterList = new CopyOnWriteArrayList>(); + @SuppressWarnings("unchecked") + COWArrayList> filterList = new COWArrayList>(new Filter[0]); /** * Add a filter to end of the filter list. @@ -48,12 +49,18 @@ * NEUTRAL, then NEUTRAL is returned. */ public FilterReply getFilterChainDecision(E event) { - for (Filter f : filterList) { - final FilterReply r = f.decide(event); + + final Filter[] filterArrray = filterList.asTypedArray(); + final int len = filterArrray.length; + + for (int i = 0; i < len; i++) { + final FilterReply r = filterArrray[i].decide(event); if (r == FilterReply.DENY || r == FilterReply.ACCEPT) { return r; } } + + // no decision return FilterReply.NEUTRAL; } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java 2016-02-25 21:15:18.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java 2017-03-30 02:48:11.000000000 +0000 @@ -21,7 +21,8 @@ * @author Ceki Gülcü */ public class OnConsoleStatusListener extends OnPrintStreamStatusListenerBase { - + + @Override protected PrintStream getPrintStream() { return System.out; diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/status/OnPrintStreamStatusListenerBase.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/status/OnPrintStreamStatusListenerBase.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/status/OnPrintStreamStatusListenerBase.java 2016-11-08 07:33:38.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/status/OnPrintStreamStatusListenerBase.java 2017-03-30 02:48:11.000000000 +0000 @@ -24,13 +24,19 @@ * Print all new incoming status messages on the on the designated PrintStream. * @author Ceki Gülcü */ -abstract class OnPrintStreamStatusListenerBase extends ContextAwareBase implements StatusListener, LifeCycle { +abstract public class OnPrintStreamStatusListenerBase extends ContextAwareBase implements StatusListener, LifeCycle { boolean isStarted = false; static final long DEFAULT_RETROSPECTIVE = 300; long retrospectiveThresold = DEFAULT_RETROSPECTIVE; - + + /** + * The prefix to place before each status message + * @since 1.1.10 + */ + String prefix; + /** * The PrintStream used by derived classes * @return @@ -39,6 +45,9 @@ private void print(Status status) { StringBuilder sb = new StringBuilder(); + if(prefix != null) + sb.append(prefix); + StatusPrinter.buildStr(sb, "", status); getPrintStream().print(sb); } @@ -82,6 +91,14 @@ } } + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + public void setRetrospective(long retrospective) { this.retrospectiveThresold = retrospective; } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java 2017-01-20 17:50:04.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java 2017-03-30 02:48:11.000000000 +0000 @@ -13,11 +13,6 @@ */ package ch.qos.logback.core.util; -import ch.qos.logback.core.Context; -import ch.qos.logback.core.CoreConstants; -import ch.qos.logback.core.rolling.helper.FileNamePattern; -import ch.qos.logback.core.spi.ContextAwareBase; - import static ch.qos.logback.core.CoreConstants.FA_FILENAME_COLLISION_MAP; import static ch.qos.logback.core.CoreConstants.RFA_FILENAME_PATTERN_COLLISION_MAP; @@ -31,6 +26,11 @@ import java.util.Map; import java.util.Properties; +import ch.qos.logback.core.Context; +import ch.qos.logback.core.CoreConstants; +import ch.qos.logback.core.rolling.helper.FileNamePattern; +import ch.qos.logback.core.spi.ContextAwareBase; + public class ContextUtil extends ContextAwareBase { public ContextUtil(Context context) { @@ -67,10 +67,10 @@ /** * Add the local host's name as a property */ - public void addHostNameAsProperty() { + public String safelyGetLocalHostName() { try { String localhostName = getLocalHostName(); - context.putProperty(CoreConstants.HOSTNAME_KEY, localhostName); + return localhostName; } catch (UnknownHostException e) { addError("Failed to get local hostname", e); } catch (SocketException e) { @@ -78,6 +78,7 @@ } catch (SecurityException e) { addError("Failed to get local hostname", e); } + return CoreConstants.UNKNOWN_LOCALHOST; } public void addProperties(Properties props) { diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/COWArrayList.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/COWArrayList.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/COWArrayList.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/COWArrayList.java 2017-03-30 02:48:11.000000000 +0000 @@ -0,0 +1,227 @@ +package ch.qos.logback.core.util; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicBoolean; + +/** + * A GC-free lock-free thread-safe implementation of the {@link List} interface for use cases where iterations over the list vastly out-number modifications on the list. + * + *

      Underneath, it wraps an instance of {@link CopyOnWriteArrayList} and exposes a copy of the array used by that instance. + * + *

      Typical use:

      + * + *
      + *   COWArrayList list = new COWArrayList(new Integer[0]);
      + *   
      + *   // modify the list
      + *   list.add(1);
      + *   list.add(2);
      + *   
      + *   Integer[] intArray = list.asTypedArray();
      + *   int sum = 0;
      + *   // iteration over the array is thread-safe
      + *   for(int i = 0; i < intArray.length; i++) {
      + *     sum != intArray[i];
      + *   }
      + * 
      + * + *

      If the list is not modified, then repetitive calls to {@link #asTypedArray()}, {@link #toArray()} and + * {@link #toArray(Object[])} are guaranteed to be GC-free. Note that iterating over the list using + * {@link COWArrayList#iterator()} and {@link COWArrayList#listIterator()} are not GC-free.

      + * + * @author Ceki Gulcu + * @since 1.1.10 + */ +public class COWArrayList implements List { + + // Implementation note: markAsStale() should always be invoked *after* list-modifying actions. + // If not, readers might get a stale array until the next write. The potential problem is nicely + // explained by Rob Eden. See https://github.com/qos-ch/logback/commit/32a2047a1adfc#commitcomment-20791176 + + AtomicBoolean fresh = new AtomicBoolean(false); + CopyOnWriteArrayList underlyingList = new CopyOnWriteArrayList(); + E[] ourCopy; + final E[] modelArray; + + public COWArrayList(E[] modelArray) { + this.modelArray = modelArray; + } + + @Override + public int size() { + return underlyingList.size(); + } + + @Override + public boolean isEmpty() { + return underlyingList.isEmpty(); + } + + @Override + public boolean contains(Object o) { + return underlyingList.contains(o); + } + + @Override + public Iterator iterator() { + return underlyingList.iterator(); + } + + private void refreshCopyIfNecessary() { + if (!isFresh()) { + refreshCopy(); + } + } + + private boolean isFresh() { + return fresh.get(); + } + + private void refreshCopy() { + ourCopy = underlyingList.toArray(modelArray); + fresh.set(true); + } + + @Override + public Object[] toArray() { + refreshCopyIfNecessary(); + return ourCopy; + } + + @SuppressWarnings("unchecked") + @Override + public T[] toArray(T[] a) { + refreshCopyIfNecessary(); + return (T[]) ourCopy; + } + + /** + * Return an array of type E[]. The returned array is intended to be iterated over. + * If the list is modified, subsequent calls to this method will return different/modified + * array instances. + * + * @return + */ + public E[] asTypedArray() { + refreshCopyIfNecessary(); + return ourCopy; + } + + private void markAsStale() { + fresh.set(false); + } + + public void addIfAbsent(E e) { + underlyingList.addIfAbsent(e); + markAsStale(); + } + + @Override + public boolean add(E e) { + boolean result = underlyingList.add(e); + markAsStale(); + return result; + } + + @Override + public boolean remove(Object o) { + boolean result = underlyingList.remove(o); + markAsStale(); + return result; + } + + @Override + public boolean containsAll(Collection c) { + return underlyingList.containsAll(c); + } + + @Override + public boolean addAll(Collection c) { + boolean result = underlyingList.addAll(c); + markAsStale(); + return result; + } + + @Override + public boolean addAll(int index, Collection col) { + boolean result = underlyingList.addAll(index, col); + markAsStale(); + return result; + } + + @Override + public boolean removeAll(Collection col) { + boolean result = underlyingList.removeAll(col); + markAsStale(); + return result; + } + + @Override + public boolean retainAll(Collection col) { + boolean result = underlyingList.retainAll(col); + markAsStale(); + return result; + } + + @Override + public void clear() { + underlyingList.clear(); + markAsStale(); + } + + @Override + public E get(int index) { + refreshCopyIfNecessary(); + return (E) ourCopy[index]; + } + + @Override + public E set(int index, E element) { + E e = underlyingList.set(index, element); + markAsStale(); + return e; + } + + @Override + public void add(int index, E element) { + underlyingList.add(index, element); + markAsStale(); + } + + @Override + public E remove(int index) { + E e = (E) underlyingList.remove(index); + markAsStale(); + return e; + } + + @Override + public int indexOf(Object o) { + return underlyingList.indexOf(o); + } + + @Override + public int lastIndexOf(Object o) { + return underlyingList.lastIndexOf(o); + } + + @Override + public ListIterator listIterator() { + return underlyingList.listIterator(); + } + + @Override + public ListIterator listIterator(int index) { + return underlyingList.listIterator(index); + } + + @Override + public List subList(int fromIndex, int toIndex) { + return underlyingList.subList(fromIndex, toIndex); + } + +} diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/FileSize.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/FileSize.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/FileSize.java 2016-03-02 22:01:59.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/FileSize.java 2017-03-30 02:48:11.000000000 +0000 @@ -91,6 +91,12 @@ return inKB + " KB"; } - return inMB + " MB"; + long inGB = size / GB_COEFFICIENT; + if(inGB == 0) { + return inMB + " MB"; + } + + return inGB + " GB"; + } } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/FixedDelay.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/FixedDelay.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/FixedDelay.java 2016-02-25 21:15:17.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/FixedDelay.java 2017-03-30 02:48:11.000000000 +0000 @@ -32,7 +32,6 @@ * @param subsequentDelay value for all other delays */ public FixedDelay(long initialDelay, long subsequentDelay) { - String s = new String(); this.nextDelay = initialDelay; this.subsequentDelay = subsequentDelay; } diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/InterruptUtil.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/InterruptUtil.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/InterruptUtil.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/InterruptUtil.java 2017-03-30 02:48:11.000000000 +0000 @@ -0,0 +1,54 @@ +package ch.qos.logback.core.util; + +import ch.qos.logback.core.Context; +import ch.qos.logback.core.spi.ContextAwareBase; + +/** + * Allows masking of interrupt flag if previously the flag is already set. Does nothing otherwise. + * + * Typical use: + * + *
      + * InterruptUtil interruptUtil = new InterruptUtil(context);
      + * 
      + * try {
      + *   interruptUtil.maskInterruptFlag();
      + *   someOtherThread.join(delay); 
      + * } catch(InterruptedException e) {
      + *   // reachable only if join does not succeed within delay.
      + *   // Without the maskInterruptFlag() call, the join() would have returned immediately
      + *   // had the current thread been interrupted previously, i.e. before entering the above block    
      + * } finally {
      + *   interruptUtil.unmaskInterruptFlag();
      + * }
      + * 
      + * @author Ceki Gulcu + * @since 1.2.2 + */ +public class InterruptUtil extends ContextAwareBase { + + final boolean previouslyInterrupted; + + public InterruptUtil(Context context) { + super(); + setContext(context); + previouslyInterrupted = Thread.currentThread().isInterrupted(); + } + + public void maskInterruptFlag() { + if (previouslyInterrupted) { + Thread.interrupted(); + } + } + + public void unmaskInterruptFlag() { + if (previouslyInterrupted) { + try { + Thread.currentThread().interrupt(); + } catch (SecurityException se) { + addError("Failed to intrreupt current thread", se); + } + } + } + +} diff -Nru logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/StatusListenerConfigHelper.java logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/StatusListenerConfigHelper.java --- logback-1.1.9/logback-core/src/main/java/ch/qos/logback/core/util/StatusListenerConfigHelper.java 2016-02-25 21:15:19.000000000 +0000 +++ logback-1.2.3/logback-core/src/main/java/ch/qos/logback/core/util/StatusListenerConfigHelper.java 2017-03-30 02:48:11.000000000 +0000 @@ -23,7 +23,7 @@ public class StatusListenerConfigHelper { public static void installIfAsked(Context context) { - String slClass = OptionHelper.getSystemProperty(CoreConstants.STATUS_LISTENER_CLASS); + String slClass = OptionHelper.getSystemProperty(CoreConstants.STATUS_LISTENER_CLASS_KEY); if (!OptionHelper.isEmpty(slClass)) { addStatusListener(context, slClass); } @@ -45,7 +45,6 @@ ((ContextAware) listener).setContext(context); boolean effectivelyAdded = context.getStatusManager().add(listener); - effectivelyAdded = true; if (effectivelyAdded && (listener instanceof LifeCycle)) { ((LifeCycle) listener).start(); // LOGBACK-767 } diff -Nru logback-1.1.9/logback-core/src/test/input/compress1.txt logback-1.2.3/logback-core/src/test/input/compress1.txt --- logback-1.1.9/logback-core/src/test/input/compress1.txt 2017-01-20 18:53:20.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/input/compress1.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ - - LOGBack: the generic, reliable, fast and flexible logging framework. - - Copyright (C) 1999-2006, QOS.ch - - This library is free software, you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation. diff -Nru logback-1.1.9/logback-core/src/test/input/compress2.txt logback-1.2.3/logback-core/src/test/input/compress2.txt --- logback-1.1.9/logback-core/src/test/input/compress2.txt 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/input/compress2.txt 2017-04-01 03:20:03.000000000 +0000 @@ -0,0 +1,34 @@ + + + + + LOGBack Home + + + + + +

      LOGBack project

      + +

      LOGBack is intended as a successor to the popular log4j + project. It was also designed by Ceki Gülcü, the founder + of the log4j project. It builds upon exerience gained in building + industrial-strength logging systems going back as far as 1999. +

      + +

      LOGBack's basic architecture is sufficiently generic so as to + apply under different circumstances. At present time, LOGBack is + divided into three modules, Core, Classic and Access. +

      + +

      The Core module lays the groundwork for the other two + modules. The Classic module can be assimilated to an improved + version of log4j. The Access module integrates with Servlet + containers to provide HTPP-access log functionality. Note that you + can easily build your own modules on top of the Core module. +

      + + + +
      + diff -Nru logback-1.1.9/logback-core/src/test/input/joran/implicitAction/statusListenerWithPrefix.xml logback-1.2.3/logback-core/src/test/input/joran/implicitAction/statusListenerWithPrefix.xml --- logback-1.1.9/logback-core/src/test/input/joran/implicitAction/statusListenerWithPrefix.xml 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/input/joran/implicitAction/statusListenerWithPrefix.xml 2017-03-30 02:48:11.000000000 +0000 @@ -0,0 +1,5 @@ + + + aPrefix + + \ No newline at end of file diff -Nru logback-1.1.9/logback-core/src/test/input/joran/inclusion/includedEntity.xml logback-1.2.3/logback-core/src/test/input/joran/inclusion/includedEntity.xml --- logback-1.1.9/logback-core/src/test/input/joran/inclusion/includedEntity.xml 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/input/joran/inclusion/includedEntity.xml 2017-03-30 02:48:11.000000000 +0000 @@ -0,0 +1,4 @@ + + + + diff -Nru logback-1.1.9/logback-core/src/test/input/joran/inclusion/topByEntity.xml logback-1.2.3/logback-core/src/test/input/joran/inclusion/topByEntity.xml --- logback-1.1.9/logback-core/src/test/input/joran/inclusion/topByEntity.xml 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/input/joran/inclusion/topByEntity.xml 2017-03-30 02:48:11.000000000 +0000 @@ -0,0 +1,10 @@ + + +]> + + + + &includedEntity; + + diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java 2016-02-25 21:15:19.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -28,6 +28,7 @@ import java.io.PrintStream; import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -128,12 +129,12 @@ public void testUTF16BE() throws UnsupportedEncodingException { ConsoleAppender ca = (ConsoleAppender) getAppender(); DummyEncoder dummyEncoder = new DummyEncoder(); - String encodingName = "UTF-16BE"; - dummyEncoder.setEncodingName(encodingName); + Charset utf16BE = Charset.forName("UTF-16BE"); + dummyEncoder.setCharset(utf16BE); ca.setEncoder(dummyEncoder); ca.start(); ca.doAppend(new Object()); - assertEquals(DummyLayout.DUMMY, new String(tee.toByteArray(), encodingName)); + assertEquals(DummyLayout.DUMMY, new String(tee.toByteArray(), utf16BE)); } @Test diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java 2016-02-25 21:15:19.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -43,7 +43,6 @@ @Test public void testBasic() throws IOException { Encoder encoder = new DummyEncoder(); - encoder.init(baos); da.setEncoder(encoder); da.start(); da.doAppend(new Object()); diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/AsyncAppenderBaseTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/AsyncAppenderBaseTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/AsyncAppenderBaseTest.java 2016-03-27 11:09:40.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/AsyncAppenderBaseTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -103,6 +103,7 @@ asyncAppenderBase.stop(); verify(delayingListAppender, 1); assertTrue(delayingListAppender.interrupted); + Thread.interrupted(); } @Test(timeout = 2000) @@ -239,10 +240,47 @@ Thread.currentThread().interrupt(); asyncAppenderBase.doAppend(new Integer(0)); assertTrue(Thread.currentThread().isInterrupted()); - // clear flag for next test + // clear interrupt flag for subsequent tests Thread.interrupted(); } + // Interruption of current thread should not prevent logging. + // See also http://jira.qos.ch/browse/LOGBACK-910 + // and https://jira.qos.ch/browse/LOGBACK-1247 + @Test + public void verifyInterruptionDoesNotPreventLogging() { + asyncAppenderBase.addAppender(listAppender); + asyncAppenderBase.start(); + asyncAppenderBase.doAppend(new Integer(0)); + Thread.currentThread().interrupt(); + asyncAppenderBase.doAppend(new Integer(1)); + asyncAppenderBase.doAppend(new Integer(1)); + assertTrue(Thread.currentThread().isInterrupted()); + // the interruption needs to be consumed + Thread.interrupted(); + asyncAppenderBase.stop(); + verify(listAppender, 3); + } + + @Test + public void verifyInterruptionFlagWhenStopping_INTERUPPTED() { + asyncAppenderBase.addAppender(listAppender); + asyncAppenderBase.start(); + Thread.currentThread().interrupt(); + asyncAppenderBase.stop(); + assertTrue(Thread.currentThread().isInterrupted()); + Thread.interrupted(); + } + + @Test + public void verifyInterruptionFlagWhenStopping_NOT_INTERUPPTED() { + asyncAppenderBase.addAppender(listAppender); + asyncAppenderBase.start(); + asyncAppenderBase.stop(); + assertFalse(Thread.currentThread().isInterrupted()); + } + + @Test public void verifyInterruptionOfWorkerIsSwallowed() { asyncAppenderBase.addAppender(delayingListAppender); diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java 2016-02-25 21:15:16.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java 2017-03-30 02:48:11.000000000 +0000 @@ -13,8 +13,7 @@ */ package ch.qos.logback.core.encoder; -import java.io.IOException; -import java.io.OutputStream; +import java.nio.charset.Charset; import ch.qos.logback.core.CoreConstants; @@ -24,14 +23,14 @@ String val = DUMMY; String fileHeader; String fileFooter; - String encodingName; + Charset charset; - public String getEncodingName() { - return encodingName; + public Charset getCharset() { + return charset; } - public void setEncodingName(String encodingName) { - this.encodingName = encodingName; + public void setCharset(Charset charset) { + this.charset = charset; } public DummyEncoder() { @@ -41,50 +40,45 @@ this.val = val; } - public void doEncode(E event) throws IOException { - writeOut(val); + public byte[] encode(E event) { + return encodeString(val); } - private void appendIfNotNull(StringBuilder sb, String s) { - if (s != null) { - sb.append(s); + byte[] encodeString(String s) { + if (charset == null) { + return s.getBytes(); + } else { + return s.getBytes(charset); } } - void writeOut(String s) throws IOException { - if (encodingName == null) { - outputStream.write(s.getBytes()); - } else { - outputStream.write(s.getBytes(encodingName)); + private void appendIfNotNull(StringBuilder sb, String s) { + if (s != null) { + sb.append(s); } } - void writeHeader() throws IOException { + byte[] header() { StringBuilder sb = new StringBuilder(); appendIfNotNull(sb, fileHeader); if (sb.length() > 0) { - sb.append(CoreConstants.LINE_SEPARATOR); // If at least one of file header or presentation header were not // null, then append a line separator. // This should be useful in most cases and should not hurt. - writeOut(sb.toString()); + sb.append(CoreConstants.LINE_SEPARATOR); } + return encodeString(sb.toString()); } - public void init(OutputStream os) throws IOException { - super.init(os); - writeHeader(); + public byte[] headerBytes() { + return header(); } - public void close() throws IOException { + public byte[] footerBytes() { if (fileFooter == null) { - return; - } - if (encodingName == null) { - outputStream.write(fileFooter.getBytes()); - } else { - outputStream.write(fileFooter.getBytes(encodingName)); + return null; } + return encodeString(fileFooter); } public String getFileHeader() { diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java 2016-02-25 21:15:18.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java 2017-03-30 02:48:11.000000000 +0000 @@ -13,17 +13,19 @@ */ package ch.qos.logback.core.encoder; -import java.io.IOException; -import java.io.OutputStream; - public class NopEncoder extends EncoderBase { - public void close() throws IOException { - } - public void doEncode(E event) throws IOException { + public byte[] encode(E event) { + return null; } - public void init(OutputStream os) throws IOException { + public byte[] headerBytes() { + return null; } + + public byte[] footerBytes() { + return null; + } + } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java 2016-02-25 21:15:18.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.encoder; - -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -import ch.qos.logback.core.testUtil.RandomUtil; -import ch.qos.logback.core.util.CoreTestConstants; - -public class ObjectEncodeDecodeTest { - - ObjectStreamEncoder encoder = new ObjectStreamEncoder(); - EventObjectInputStream eventStream; - - int diff = RandomUtil.getPositiveInt(); - protected String randomOutputDir = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "/"; - - @Before - public void setUp() { - File randomOupurDirFile = new File(randomOutputDir); - randomOupurDirFile.mkdirs(); - } - - void encodeList(File file, List list) throws IOException { - FileOutputStream fos = new FileOutputStream(file); - encoder.init(fos); - for (String s : list) { - encoder.doEncode(s); - } - encoder.close(); - fos.close(); - } - - List decodeList(File file) throws IOException { - FileInputStream fis = new FileInputStream(file); - eventStream = new EventObjectInputStream(fis); - List back = new ArrayList(); - String e; - while ((e = eventStream.readEvent()) != null) { - back.add(e); - } - return back; - } - - @Test - public void singleBatch() throws IOException { - File file = new File(randomOutputDir + "x.lbo"); - - List witness = new ArrayList(); - for (int i = 0; i < 10; i++) { - witness.add("hello" + i); - } - encodeList(file, witness); - List back = decodeList(file); - assertEquals(witness, back); - } - - @Test - public void multipleBatches() throws IOException { - File file = new File(randomOutputDir + "m.lbo"); - - List witness = new ArrayList(); - for (int i = 0; i < 100 * 10; i++) { - witness.add("hello" + i); - } - encodeList(file, witness); - List back = decodeList(file); - assertEquals(witness, back); - } - -} diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/encoder/PackageTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/encoder/PackageTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/encoder/PackageTest.java 2016-02-25 21:15:18.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/encoder/PackageTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -17,6 +17,6 @@ import org.junit.runners.Suite; @RunWith(Suite.class) -@Suite.SuiteClasses({ ByteArrayUtilTest.class, ObjectEncodeDecodeTest.class }) +@Suite.SuiteClasses({ ByteArrayUtilTest.class}) public class PackageTest { } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java 2016-03-11 21:05:58.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -71,6 +71,8 @@ static final String TOP_BY_URL = INCLUSION_DIR_PREFIX + "topByUrl.xml"; + static final String TOP_BY_ENTITY = INCLUSION_DIR_PREFIX + "topByEntity.xml"; + static final String INCLUDE_BY_RESOURCE = INCLUSION_DIR_PREFIX + "topByResource.xml"; static final String INCLUDED_FILE = INCLUSION_DIR_PREFIX + "included.xml"; @@ -213,11 +215,19 @@ tc.doConfigure(MULTI_INCLUDE_BY_FILE); verifyConfig(new String[] { "IA", "IB", "SECOND" }); } - + + @Test + public void includeAsEntity() throws JoranException { + tc.doConfigure(TOP_BY_ENTITY); + verifyConfig(new String[] { "EA", "EB" }); + } + void verifyConfig(String[] expected) { Stack witness = new Stack(); witness.addAll(Arrays.asList(expected)); assertEquals(witness, stackAction.getStack()); } + + } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java 2016-02-25 21:15:19.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -26,6 +26,7 @@ import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.joran.spi.InterpretationContext; import ch.qos.logback.core.status.ErrorStatus; +import ch.qos.logback.core.status.Status; import ch.qos.logback.core.util.CoreTestConstants; import ch.qos.logback.core.util.StatusPrinter; @@ -148,13 +149,13 @@ } private boolean checkError() { - Iterator it = context.getStatusManager().getCopyOfStatusList().iterator(); + Iterator it = context.getStatusManager().getCopyOfStatusList().iterator(); ErrorStatus es = (ErrorStatus) it.next(); return PropertyAction.INVALID_ATTRIBUTES.equals(es.getMessage()); } private boolean checkFileErrors() { - Iterator it = context.getStatusManager().getCopyOfStatusList().iterator(); + Iterator it = context.getStatusManager().getCopyOfStatusList().iterator(); ErrorStatus es1 = (ErrorStatus) it.next(); return "Could not find properties file [toto].".equals(es1.getMessage()); } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java 2016-02-25 21:15:17.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -24,7 +24,9 @@ import ch.qos.logback.core.joran.SimpleConfigurator; import ch.qos.logback.core.joran.action.Action; +import ch.qos.logback.core.joran.action.StatusListenerAction; import ch.qos.logback.core.joran.spi.ElementSelector; +import ch.qos.logback.core.status.StatusChecker; import ch.qos.logback.core.util.CoreTestConstants; import ch.qos.logback.core.util.StatusPrinter; @@ -34,12 +36,14 @@ FruitContext fruitContext = new FruitContext(); SimpleConfigurator simpleConfigurator; - + StatusChecker checker = new StatusChecker(fruitContext); + @Before public void setUp() throws Exception { fruitContext.setName("fruits"); HashMap rulesMap = new HashMap(); rulesMap.put(new ElementSelector("/context/"), new FruitContextAction()); + rulesMap.put(new ElementSelector("/context/statusListener"), new StatusListenerAction()); simpleConfigurator = new SimpleConfigurator(rulesMap); simpleConfigurator.setContext(fruitContext); } @@ -115,6 +119,18 @@ } catch (Exception je) { StatusPrinter.print(fruitContext); throw je; + } + } + + @Test + public void statusListenerWithPrefix() throws Exception { + try { + simpleConfigurator.doConfigure(IMPLCIT_DIR + "statusListenerWithPrefix.xml"); + StatusPrinter.print(fruitContext); + checker.assertIsErrorFree(); + } catch (Exception je) { + StatusPrinter.print(fruitContext); + throw je; } } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/util/Citrus.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/util/Citrus.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/util/Citrus.java 2016-12-05 18:39:02.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/util/Citrus.java 2017-03-30 02:48:11.000000000 +0000 @@ -1,15 +1,25 @@ package ch.qos.logback.core.joran.util; -public class Citrus { +public abstract class Citrus { - // should match name of the single property of this class public static final String PRECARP_PROPERTY_NAME = "pericarp"; + public static final String PREFIX_PROPERTY_NAME = "prefix"; + @SuppressWarnings("unused") private T pericarp; + String prefix; + public void setPericarp(T pericarp) { this.pericarp = pericarp; } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public abstract void foo(); + } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/util/Orange.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/util/Orange.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/util/Orange.java 2016-12-05 18:31:34.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/util/Orange.java 2017-03-30 02:48:11.000000000 +0000 @@ -6,4 +6,8 @@ System.out.println("Orange.setPericarp"); super.setPericarp(pericarp); } + + @Override + public void foo() { + } } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java 2016-12-05 18:46:36.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -33,6 +33,7 @@ import ch.qos.logback.core.spi.FilterReply; import ch.qos.logback.core.status.StatusChecker; import ch.qos.logback.core.util.AggregationType; +import ch.qos.logback.core.util.StatusPrinter; public class PropertySetterTest { @@ -233,8 +234,9 @@ PropertySetter orangeSetter = new PropertySetter(new BeanDescriptionCache(context), orange); assertEquals(AggregationType.AS_BASIC_PROPERTY, orangeSetter.computeAggregationType(Citrus.PRECARP_PROPERTY_NAME)); + assertEquals(AggregationType.AS_BASIC_PROPERTY, orangeSetter.computeAggregationType(Citrus.PREFIX_PROPERTY_NAME)); - + StatusPrinter.print(context); checker.assertIsWarningOrErrorFree(); } } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/net/AbstractSocketAppenderTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/net/AbstractSocketAppenderTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/net/AbstractSocketAppenderTest.java 2016-03-16 16:15:45.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/net/AbstractSocketAppenderTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,527 +0,0 @@ -/** - * Logback: the reliable, generic, fast and flexible logging framework. - * Copyright (C) 1999-2015, 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.net; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.contains; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.Serializable; -import java.net.InetAddress; -import java.net.Socket; -import java.util.concurrent.LinkedBlockingDeque; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; - -import ch.qos.logback.core.net.mock.MockContext; -import ch.qos.logback.core.spi.PreSerializationTransformer; -import ch.qos.logback.core.util.Duration; -import ch.qos.logback.core.util.ExecutorServiceUtil; - -/** - * Unit tests for {@link AbstractSocketAppender}. - * - * @author Carl Harris - * @author Sebastian Gröbler - */ -public class AbstractSocketAppenderTest { - - /** - * Timeout used for all blocking operations in multi-threading contexts. - */ - private static final int TIMEOUT = 1000; - - private ScheduledExecutorService executorService = spy((ScheduledExecutorService) ExecutorServiceUtil.newScheduledExecutorService()); - private MockContext mockContext = new MockContext(executorService); - private PreSerializationTransformer preSerializationTransformer = spy(new StringPreSerializationTransformer()); - private Socket socket = mock(Socket.class); - private SocketConnector socketConnector = mock(SocketConnector.class); - private AutoFlushingObjectWriter objectWriter = mock(AutoFlushingObjectWriter.class); - private ObjectWriterFactory objectWriterFactory = mock(ObjectWriterFactory.class); - private LinkedBlockingDeque deque = spy(new LinkedBlockingDeque(1)); - private QueueFactory queueFactory = mock(QueueFactory.class); - private InstrumentedSocketAppender appender = spy(new InstrumentedSocketAppender(preSerializationTransformer, queueFactory, objectWriterFactory, - socketConnector)); - - @Before - public void setupValidAppenderWithMockDependencies() throws Exception { - - doReturn(objectWriter).when(objectWriterFactory).newAutoFlushingObjectWriter(any(OutputStream.class)); - doReturn(deque).when(queueFactory). newLinkedBlockingDeque(anyInt()); - - appender.setContext(mockContext); - appender.setRemoteHost("localhost"); - } - - @After - public void tearDown() throws Exception { - appender.stop(); - assertFalse(appender.isStarted()); - - executorService.shutdownNow(); - assertTrue(executorService.awaitTermination(TIMEOUT, TimeUnit.MILLISECONDS)); - } - - @Test - public void failsToStartWithoutValidPort() throws Exception { - - // given - appender.setPort(-1); - - // when - appender.start(); - - // then - assertFalse(appender.isStarted()); - verify(appender).addError(contains("port")); - } - - @Test - public void failsToStartWithoutValidRemoteHost() throws Exception { - - // given - appender.setRemoteHost(null); - - // when - appender.start(); - - // then - assertFalse(appender.isStarted()); - verify(appender).addError(contains("remote host")); - } - - @Test - public void failsToStartWithNegativeQueueSize() throws Exception { - - // given - appender.setQueueSize(-1); - - // when - appender.start(); - - // then - assertFalse(appender.isStarted()); - verify(appender).addError(contains("Queue size must be greater than zero")); - } - - @Test - public void failsToStartWithUnresolvableRemoteHost() throws Exception { - - // given - appender.setRemoteHost("NOT.A.VALID.REMOTE.HOST.NAME"); - - // when - appender.start(); - - // then - assertFalse(appender.isStarted()); - verify(appender).addError(contains("unknown host")); - } - - @Test - public void startsButOutputsWarningWhenQueueSizeIsZero() throws Exception { - - // given - appender.setQueueSize(0); - - // when - appender.start(); - - // then - assertTrue(appender.isStarted()); - verify(appender).addWarn("Queue size of zero is deprecated, use a size of one to indicate synchronous processing"); - } - - @Test - public void startsWithValidParameters() throws Exception { - - // when - appender.start(); - - // then - assertTrue(appender.isStarted()); - } - - @Test - public void createsSocketConnectorWithConfiguredParameters() throws Exception { - - // given - appender.setReconnectionDelay(new Duration(42)); - appender.setRemoteHost("localhost"); - appender.setPort(21); - - // when - appender.start(); - - // then - verify(appender, timeout(TIMEOUT)).newConnector(InetAddress.getByName("localhost"), 21, 0, 42); - } - - @Test - public void addsInfoMessageWhenSocketConnectionWasEstablished() throws Exception { - - // when - mockOneSuccessfulSocketConnection(); - appender.start(); - - // then - verify(appender, timeout(TIMEOUT)).addInfo(contains("connection established")); - } - - @Test - public void addsInfoMessageWhenSocketConnectionFailed() throws Exception { - - // given - mockOneSuccessfulSocketConnection(); - doThrow(new IOException()).when(objectWriterFactory).newAutoFlushingObjectWriter(any(OutputStream.class)); - appender.start(); - - // when - appender.append("some event"); - - // then - verify(appender, timeout(TIMEOUT).atLeastOnce()).addInfo(contains("connection failed")); - } - - @Test - public void closesSocketOnException() throws Exception { - - // given - mockOneSuccessfulSocketConnection(); - doThrow(new IOException()).when(objectWriterFactory).newAutoFlushingObjectWriter(any(OutputStream.class)); - appender.start(); - - // when - appender.append("some event"); - - // then - verify(socket, timeout(TIMEOUT).atLeastOnce()).close(); - } - - @Test - public void addsInfoMessageWhenSocketConnectionClosed() throws Exception { - - // given - mockOneSuccessfulSocketConnection(); - doThrow(new IOException()).when(objectWriterFactory).newAutoFlushingObjectWriter(any(OutputStream.class)); - appender.start(); - - // when - appender.append("some event"); - - // then - verify(appender, timeout(TIMEOUT).atLeastOnce()).addInfo(contains("connection closed")); - } - - @Test - public void shutsDownOnInterruptWhileWaitingForEvent() throws Exception { - - // given - mockOneSuccessfulSocketConnection(); - doThrow(new InterruptedException()).when(deque).takeFirst(); - - // when - appender.start(); - - // then - verify(deque, timeout(TIMEOUT)).takeFirst(); - } - - @Test - public void shutsDownOnInterruptWhileWaitingForSocketConnection() throws Exception { - - // given - doThrow(new InterruptedException()).when(socketConnector).call(); - - // when - appender.start(); - - // then - verify(socketConnector, timeout(TIMEOUT)).call(); - } - - @Test - public void addsInfoMessageWhenShuttingDownDueToInterrupt() throws Exception { - - // given - doThrow(new InterruptedException()).when(socketConnector).call(); - - // when - appender.start(); - - // then - verify(appender, timeout(TIMEOUT)).addInfo(contains("shutting down")); - } - - @Test - public void offersEventsToTheEndOfTheDeque() throws Exception { - - // given - appender.start(); - - // when - appender.append("some event"); - - // then - verify(deque).offer(eq("some event"), anyLong(), any(TimeUnit.class)); - } - - @Test - public void doesNotQueueAnyEventsWhenStopped() throws Exception { - - // given - appender.start(); - appender.stop(); - - // when - appender.append("some event"); - - // then - verifyZeroInteractions(deque); - } - - @Test - public void addsInfoMessageWhenEventCouldNotBeQueuedInConfiguredTimeoutDueToQueueSizeLimitation() throws Exception { - - // given - long eventDelayLimit = 42; - doReturn(false).when(deque).offer("some event", eventDelayLimit, TimeUnit.MILLISECONDS); - appender.setEventDelayLimit(new Duration(eventDelayLimit)); - appender.start(); - - // when - appender.append("some event"); - - // then - verify(appender).addInfo("Dropping event due to timeout limit of [" + eventDelayLimit + " milliseconds] being exceeded"); - } - - @Test - public void takesEventsFromTheFrontOfTheDeque() throws Exception { - - // given - mockOneSuccessfulSocketConnection(); - appender.start(); - awaitStartOfEventDispatching(); - - // when - appender.append("some event"); - - // then - verify(deque, timeout(TIMEOUT).atLeastOnce()).takeFirst(); - } - - @Test - public void reAddsEventAtTheFrontOfTheDequeWhenTransmissionFails() throws Exception { - - // given - mockOneSuccessfulSocketConnection(); - doThrow(new IOException()).when(objectWriter).write(anyObject()); - appender.start(); - awaitStartOfEventDispatching(); - - // when - appender.append("some event"); - - // then - verify(deque, timeout(TIMEOUT).atLeastOnce()).offerFirst("some event"); - } - - @Test - public void addsErrorMessageWhenAppendingIsInterruptedWhileWaitingForTheQueueToAcceptTheEvent() throws Exception { - - // given - final InterruptedException interruptedException = new InterruptedException(); - doThrow(interruptedException).when(deque).offer(eq("some event"), anyLong(), any(TimeUnit.class)); - appender.start(); - - // when - appender.append("some event"); - - // then - verify(appender).addError("Interrupted while appending event to SocketAppender", interruptedException); - } - - @Test - public void postProcessesEventsBeforeTransformingItToASerializable() throws Exception { - - // given - mockOneSuccessfulSocketConnection(); - appender.start(); - awaitStartOfEventDispatching(); - - // when - appender.append("some event"); - awaitAtLeastOneEventToBeDispatched(); - - // then - InOrder inOrder = inOrder(appender, preSerializationTransformer); - inOrder.verify(appender).postProcessEvent("some event"); - inOrder.verify(preSerializationTransformer).transform("some event"); - } - - @Test - public void writesSerializedEventToStream() throws Exception { - - // given - mockOneSuccessfulSocketConnection(); - when(preSerializationTransformer.transform("some event")).thenReturn("some serialized event"); - appender.start(); - awaitStartOfEventDispatching(); - - // when - appender.append("some event"); - - // then - verify(objectWriter, timeout(TIMEOUT)).write("some serialized event"); - } - - @Test - public void addsInfoMessageWhenEventIsBeingDroppedBecauseOfConnectionProblemAndDequeCapacityLimitReached() throws Exception { - - // given - mockOneSuccessfulSocketConnection(); - doThrow(new IOException()).when(objectWriter).write(anyObject()); - doReturn(false).when(deque).offerFirst("some event"); - appender.start(); - awaitStartOfEventDispatching(); - reset(appender); - - // when - appender.append("some event"); - - // then - verify(appender, timeout(TIMEOUT)).addInfo("Dropping event due to socket connection error and maxed out deque capacity"); - } - - @Test - public void reEstablishesSocketConnectionOnConnectionDropWhenWritingEvent() throws Exception { - - // given - mockTwoSuccessfulSocketConnections(); - doThrow(new IOException()).when(objectWriter).write(anyObject()); - appender.start(); - awaitStartOfEventDispatching(); - - // when - appender.append("some event"); - - // then - verify(objectWriterFactory, timeout(TIMEOUT).atLeast(2)).newAutoFlushingObjectWriter(any(OutputStream.class)); - } - - @Test - public void triesToReEstablishSocketConnectionIfItFailed() throws Exception { - - // given - mockOneSuccessfulSocketConnection(); - doThrow(new IOException()).when(socket).getOutputStream(); - appender.start(); - - // when - appender.append("some event"); - - // then - verify(socketConnector, timeout(TIMEOUT).atLeast(2)).call(); - } - - @Test - public void usesConfiguredAcceptConnectionTimeoutAndResetsSocketTimeoutAfterSuccessfulConnection() throws Exception { - - // when - mockOneSuccessfulSocketConnection(); - appender.setAcceptConnectionTimeout(42); - appender.start(); - awaitStartOfEventDispatching(); - - // then - InOrder inOrder = inOrder(socket); - inOrder.verify(socket).setSoTimeout(42); - inOrder.verify(socket).setSoTimeout(0); - } - - private void awaitAtLeastOneEventToBeDispatched() throws IOException { - verify(objectWriter, timeout(TIMEOUT)).write(anyString()); - } - - private void awaitStartOfEventDispatching() throws InterruptedException { - verify(deque, timeout(TIMEOUT)).takeFirst(); - } - - private void mockOneSuccessfulSocketConnection() throws InterruptedException { - doReturn(socket).doReturn(null).when(socketConnector).call(); - } - - private void mockTwoSuccessfulSocketConnections() throws InterruptedException { - doReturn(socket).doReturn(socket).doReturn(null).when(socketConnector).call(); - } - - private static class InstrumentedSocketAppender extends AbstractSocketAppender { - - private PreSerializationTransformer preSerializationTransformer; - private SocketConnector socketConnector; - - public InstrumentedSocketAppender(PreSerializationTransformer preSerializationTransformer, QueueFactory queueFactory, - ObjectWriterFactory objectWriterFactory, SocketConnector socketConnector) { - super(queueFactory, objectWriterFactory); - this.preSerializationTransformer = preSerializationTransformer; - this.socketConnector = socketConnector; - } - - @Override - protected void postProcessEvent(String event) { - } - - @Override - protected PreSerializationTransformer getPST() { - return preSerializationTransformer; - } - - @Override - protected SocketConnector newConnector(InetAddress address, int port, long initialDelay, long retryDelay) { - return socketConnector; - } - } - - private static class StringPreSerializationTransformer implements PreSerializationTransformer { - - @Override - public Serializable transform(String event) { - return event; - } - } -} diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/net/HardenedObjectInputStreamTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/net/HardenedObjectInputStreamTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/net/HardenedObjectInputStreamTest.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/net/HardenedObjectInputStreamTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -0,0 +1,58 @@ +package ch.qos.logback.core.net; + +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class HardenedObjectInputStreamTest { + + ByteArrayOutputStream bos; + ObjectOutputStream oos; + HardenedObjectInputStream inputStream; + String[] whitelist = new String[] {Innocent.class.getName()}; + + @Before + public void setUp() throws Exception { + bos = new ByteArrayOutputStream(); + oos = new ObjectOutputStream(bos); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void smoke() throws ClassNotFoundException, IOException { + Innocent innocent = new Innocent(); + innocent.setAnInt(1); + innocent.setAnInteger(2); + innocent.setaString("smoke"); + Innocent back = writeAndRead(innocent); + assertEquals(innocent, back); + } + + + + private Innocent writeAndRead(Innocent innocent) throws IOException, ClassNotFoundException { + writeObject(oos, innocent); + ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); + inputStream = new HardenedObjectInputStream(bis, whitelist); + Innocent fooBack = (Innocent) inputStream.readObject(); + inputStream.close(); + return fooBack; + } + + private void writeObject(ObjectOutputStream oos, Object o) throws IOException { + oos.writeObject(o); + oos.flush(); + oos.close(); + } + +} diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/net/Innocent.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/net/Innocent.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/net/Innocent.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/net/Innocent.java 2017-03-30 02:48:11.000000000 +0000 @@ -0,0 +1,69 @@ +package ch.qos.logback.core.net; + +public class Innocent implements java.io.Serializable { + + private static final long serialVersionUID = -1227008349289885025L; + + int anInt; + Integer anInteger; + String aString; + + public int getAnInt() { + return anInt; + } + + public void setAnInt(int anInt) { + this.anInt = anInt; + } + + public Integer getAnInteger() { + return anInteger; + } + + public void setAnInteger(Integer anInteger) { + this.anInteger = anInteger; + } + + public String getaString() { + return aString; + } + + public void setaString(String aString) { + this.aString = aString; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((aString == null) ? 0 : aString.hashCode()); + result = prime * result + anInt; + result = prime * result + ((anInteger == null) ? 0 : anInteger.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Innocent other = (Innocent) obj; + if (aString == null) { + if (other.aString != null) + return false; + } else if (!aString.equals(other.aString)) + return false; + if (anInt != other.anInt) + return false; + if (anInteger == null) { + if (other.anInteger != null) + return false; + } else if (!anInteger.equals(other.anInteger)) + return false; + return true; + } + +} diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/net/PackageTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/net/PackageTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/net/PackageTest.java 2016-02-25 21:15:19.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/net/PackageTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -17,7 +17,7 @@ import org.junit.runners.Suite; @RunWith(Suite.class) -@Suite.SuiteClasses({ AbstractSocketAppenderTest.class, DefaultSocketConnectorTest.class, AbstractSSLSocketAppenderTest.class, +@Suite.SuiteClasses({ DefaultSocketConnectorTest.class, AbstractSSLSocketAppenderTest.class, ch.qos.logback.core.net.server.PackageTest.class, ch.qos.logback.core.net.ssl.PackageTest.class }) public class PackageTest { } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java 2016-02-25 21:15:16.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -15,7 +15,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import org.junit.Test; diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/recovery/ResilientOutputStreamTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/recovery/ResilientOutputStreamTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/recovery/ResilientOutputStreamTest.java 2016-11-08 07:33:38.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/recovery/ResilientOutputStreamTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -23,6 +23,7 @@ import ch.qos.logback.core.Context; import ch.qos.logback.core.ContextBase; +import ch.qos.logback.core.FileAppender; import ch.qos.logback.core.testUtil.RandomUtil; import ch.qos.logback.core.util.CoreTestConstants; @@ -43,7 +44,7 @@ @Test public void verifyRecuperationAfterFailure() throws Exception { File file = new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "resilient" + diff + ".log"); - ResilientFileOutputStream rfos = new ResilientFileOutputStream(file, true); + ResilientFileOutputStream rfos = new ResilientFileOutputStream(file, true, FileAppender.DEFAULT_BUFFER_SIZE); rfos.setContext(context); ResilientFileOutputStream spy = spy(rfos); diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java 2016-12-12 12:17:38.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -19,6 +19,7 @@ import java.util.Date; import java.util.Locale; +import java.util.TimeZone; import org.junit.After; import org.junit.Before; @@ -29,6 +30,8 @@ public class RollingCalendarTest { + String dailyPattern = "yyyy-MM-dd"; + @Before public void setUp() { @@ -193,4 +196,49 @@ } } + @Test + public void basicPeriodBarriersCrossed() { + RollingCalendar rc = new RollingCalendar(dailyPattern, TimeZone.getTimeZone("CET"), Locale.US); + // Thu Jan 26 19:46:58 CET 2017, GMT offset = -1h + long start = 1485456418969L; + // Fri Jan 27 19:46:58 CET 2017, GMT offset = -1h + long end = start+CoreConstants.MILLIS_IN_ONE_DAY; + assertEquals(1, rc.periodBarriersCrossed(start, end)); + } + + @Test + public void testPeriodBarriersCrossedWhenGoingIntoDaylightSaving() { + RollingCalendar rc = new RollingCalendar(dailyPattern, TimeZone.getTimeZone("CET"), Locale.US); + // Sun Mar 26 00:02:03 CET 2017, GMT offset = -1h + long start = 1490482923333L; + // Mon Mar 27 00:02:03 CEST 2017, GMT offset = -2h + long end = 1490565723333L; + + assertEquals(1, rc.periodBarriersCrossed(start, end)); + } + + @Test + public void testPeriodBarriersCrossedWhenLeavingDaylightSaving() { + RollingCalendar rc = new RollingCalendar(dailyPattern, TimeZone.getTimeZone("CET"), Locale.US); + // Sun Oct 29 00:02:03 CEST 2017, GMT offset = -2h + long start = 1509228123333L;//1490482923333L+217*CoreConstants.MILLIS_IN_ONE_DAY-CoreConstants.MILLIS_IN_ONE_HOUR; + // Mon Oct 30 00:02:03 CET 2017, GMT offset = -1h + long end = 1509228123333L+25*CoreConstants.MILLIS_IN_ONE_HOUR; + assertEquals(1, rc.periodBarriersCrossed(start, end)); + } + + @Test + public void testPeriodBarriersCrossedJustBeforeEnteringDaylightSaving() { + RollingCalendar rc = new RollingCalendar(dailyPattern, TimeZone.getTimeZone("CET"), Locale.US); + // Sun Mar 26 22:18:38 CEST 2017, GMT offset = +2h + long start = 1490559518333L; + System.out.println(new Date(start)); + + // Mon Mar 27 00:05:18 CEST 2017, GMT offset = +2h + long end = 1490565918333L; + System.out.println(new Date(end)); + assertEquals(1, rc.periodBarriersCrossed(start, end)); + + + } } \ No newline at end of file diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java 2016-05-13 17:14:35.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java 2017-03-30 02:48:11.000000000 +0000 @@ -279,6 +279,6 @@ new RuntimeException("unexpected exception while testing", e); } } - + futureList.clear(); } } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java 2016-05-12 16:19:44.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -22,6 +22,7 @@ import ch.qos.logback.core.encoder.EchoEncoder; import ch.qos.logback.core.util.CoreTestConstants; import ch.qos.logback.core.util.FileSize; +import ch.qos.logback.core.util.StatusPrinter; public class SizeBasedRollingTest extends ScaffoldingForRollingTests { @@ -83,6 +84,7 @@ } rfa.stop(); + StatusPrinter.print(context); existenceCheck(expectedFilenameList); reverseSortedContentCheck(randomOutputDir, runLength, prefix); } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemoval_Test.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemoval_Test.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemoval_Test.java 2016-11-04 18:58:46.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemoval_Test.java 2017-03-30 02:48:11.000000000 +0000 @@ -129,7 +129,7 @@ long generateDailyRolloverAndCheckFileCount(ConfigParameters cp) { long millisAtEnd = generateDailyRollover(cp); int periodBarriersCrossed = computeCrossedDayBarriers(currentTime, millisAtEnd); - System.out.println("**** " + periodBarriersCrossed); + System.out.println("**** periodBarriersCrossed=" + periodBarriersCrossed); checkFileCount(expectedCountWithoutFoldersWithInactivity(cp.maxHistory, periodBarriersCrossed, cp.startInactivity + cp.numInactivityPeriods)); return millisAtEnd; } @@ -427,25 +427,34 @@ System.out.println("cp.periodDurationInMillis=" + cp.periodDurationInMillis + ", tickDuration=:" + tickDuration + ", runLength=" + runLength); for (int i = 0; i <= runLength; i++) { + Date currentDate = new Date(tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime()); if (i < startInactivityIndex || i > endInactivityIndex) { StringBuilder sb = new StringBuilder("Hello"); + String currentDateStr = currentDate.toString(); String iAsString = Integer.toString(i); - SpacePadder.spacePad(sb, 66 + (6 - iAsString.length())); + sb.append(currentDateStr); + SpacePadder.spacePad(sb, 66 + (3 - iAsString.length() - currentDateStr.length())); + sb.append(iAsString); rfa.doAppend(sb.toString()); - } else { - @SuppressWarnings("unused") - Date d = new Date(tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime()); - System.out.print(""); - } + } tbrp.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(addTime(tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime(), tickDuration)); + add(tbrp.compressionFuture); add(tbrp.cleanUpFuture); waitForJobsToComplete(); } + + + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } rfa.stop(); - System.out.println(new Date(tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime())); + System.out.println("Current time at end of loop: "+new Date(tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime())); return tbrp.timeBasedFileNamingAndTriggeringPolicy.getCurrentTime(); } diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/testUtil/DelayingListAppender.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/testUtil/DelayingListAppender.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/testUtil/DelayingListAppender.java 2016-03-23 20:50:28.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/testUtil/DelayingListAppender.java 2017-03-30 02:48:11.000000000 +0000 @@ -29,6 +29,7 @@ try { Thread.sleep(delay); } catch (InterruptedException ie) { + // consume InterruptedException interrupted = true; } super.append(e); diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/util/COWArrayListTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/util/COWArrayListTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/util/COWArrayListTest.java 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/util/COWArrayListTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -0,0 +1,44 @@ +package ch.qos.logback.core.util; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class COWArrayListTest { + + Integer[] model = new Integer[0]; + COWArrayList cowaList = new COWArrayList(model); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void basicToArray() { + cowaList.add(1); + Object[] result = cowaList.toArray(); + assertArrayEquals(new Integer[] { 1 }, result); + } + + @Test + public void basicToArrayWithModel() { + cowaList.add(1); + Integer[] result = cowaList.toArray(model); + assertArrayEquals(new Integer[] { 1 }, result); + } + + + @Test + public void basicToArrayTyped() { + cowaList.add(1); + Integer[] result = cowaList.asTypedArray(); + assertArrayEquals(new Integer[] { 1 }, result); + } + +} diff -Nru logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java --- logback-1.1.9/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java 2016-03-02 21:58:16.000000000 +0000 +++ logback-1.2.3/logback-core/src/test/java/ch/qos/logback/core/util/FileSizeTest.java 2017-03-30 02:48:11.000000000 +0000 @@ -68,5 +68,10 @@ FileSize fs = new FileSize(8*1024*1024+3*1024); assertEquals("8 MB", fs.toString()); } + + { + FileSize fs = new FileSize(8*1024*1024*1024L); + assertEquals("8 GB", fs.toString()); + } } } diff -Nru logback-1.1.9/logback-examples/pom.xml logback-1.2.3/logback-examples/pom.xml --- logback-1.1.9/logback-examples/pom.xml 2017-01-20 18:37:25.000000000 +0000 +++ logback-1.2.3/logback-examples/pom.xml 2017-04-01 03:15:20.000000000 +0000 @@ -1,3 +1,4 @@ + @@ -7,7 +8,7 @@ ch.qos.logback logback-parent - 1.1.9 + 1.2.3 logback-examples @@ -40,7 +41,7 @@ javax.servlet - servlet-api + javax.servlet-api compile true @@ -89,7 +90,7 @@ cobertura-maven-plugin ${cobertura.maven.plugin.version} - + chapters/**/*.class @@ -97,7 +98,6 @@ - \ No newline at end of file diff -Nru logback-1.1.9/logback-examples/setClasspath.cmd logback-1.2.3/logback-examples/setClasspath.cmd --- logback-1.1.9/logback-examples/setClasspath.cmd 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/logback-examples/setClasspath.cmd 2017-04-01 04:26:02.000000000 +0000 @@ -5,9 +5,9 @@ set LB_HOME=c:/SET/THIS/PARAMETER/TO/THE/FOLDER/WHERE/YOU/INSTALLED/LOGBACK REM echo %LB_HOME% -set CLASSPATH=%CLASSPATH%;%LB_HOME%/logback-classic-1.1.9.jar -set CLASSPATH=%CLASSPATH%;%LB_HOME%/logback-core-1.1.9.jar -set CLASSPATH=%CLASSPATH%;%LB_HOME%/logback-examples/logback-examples-1.1.9.jar -set CLASSPATH=%CLASSPATH%;%LB_HOME%/logback-examples/lib/slf4j-api-1.7.22.jar +set CLASSPATH=%CLASSPATH%;%LB_HOME%/logback-classic-1.2.3.jar +set CLASSPATH=%CLASSPATH%;%LB_HOME%/logback-core-1.2.3.jar +set CLASSPATH=%CLASSPATH%;%LB_HOME%/logback-examples/logback-examples-1.2.3.jar +set CLASSPATH=%CLASSPATH%;%LB_HOME%/logback-examples/lib/slf4j-api-1.7.25.jar REM echo %CLASSPATH% diff -Nru logback-1.1.9/logback-examples/setClasspath.sh logback-1.2.3/logback-examples/setClasspath.sh --- logback-1.1.9/logback-examples/setClasspath.sh 2017-01-20 18:53:49.000000000 +0000 +++ logback-1.2.3/logback-examples/setClasspath.sh 2017-04-01 04:26:02.000000000 +0000 @@ -6,10 +6,10 @@ LB_HOME=/SET/THIS/PARAMETER/TO/THE/DIRECTORY/WHERE/YOU/INSTALLED/LOGBACK -CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-classic-1.1.9.jar" -CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-core-1.1.9.jar" -CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-examples/logback-examples-1.1.9.jar" -CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-examples/lib/slf4j-api-1.7.22.jar" +CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-classic-1.2.3.jar" +CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-core-1.2.3.jar" +CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-examples/logback-examples-1.2.3.jar" +CLASSPATH="${CLASSPATH}:${LB_HOME}/logback-examples/lib/slf4j-api-1.7.25.jar" export CLASSPATH diff -Nru logback-1.1.9/logback-examples/src/main/java/chapters/appenders/CountingConsoleAppender.java logback-1.2.3/logback-examples/src/main/java/chapters/appenders/CountingConsoleAppender.java --- logback-1.1.9/logback-examples/src/main/java/chapters/appenders/CountingConsoleAppender.java 2016-02-25 21:15:53.000000000 +0000 +++ logback-1.2.3/logback-examples/src/main/java/chapters/appenders/CountingConsoleAppender.java 2017-03-30 02:48:11.000000000 +0000 @@ -13,18 +13,16 @@ */ package chapters.appenders; -import java.io.IOException; - -import ch.qos.logback.classic.encoder.PatternLayoutEncoder; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.AppenderBase; +import ch.qos.logback.core.Layout; public class CountingConsoleAppender extends AppenderBase { static int DEFAULT_LIMIT = 10; int counter = 0; int limit = DEFAULT_LIMIT; - PatternLayoutEncoder encoder; + Layout layout; public void setLimit(int limit) { this.limit = limit; @@ -36,15 +34,13 @@ @Override public void start() { - if (this.encoder == null) { - addError("No encoder set for the appender named [" + name + "]."); + if (this.layout == null) { + addError("No layout set for the appender named [" + name + "]."); return; } - try { - encoder.init(System.out); - } catch (IOException e) { - } + String header = layout.getFileHeader(); + System.out.print(header); super.start(); } @@ -52,21 +48,20 @@ if (counter >= limit) { return; } - // output the events as formatted by the wrapped layout - try { - this.encoder.doEncode(event); - } catch (IOException e) { - } + // output the events as formatted by patternLayout + String eventStr = this.layout.doLayout(event); + + System.out.print(eventStr); // prepare for next event counter++; } - public PatternLayoutEncoder getEncoder() { - return encoder; + public Layout getLayout() { + return layout; } - public void setEncoder(PatternLayoutEncoder encoder) { - this.encoder = encoder; + public void setLayout(Layout layout) { + this.layout = layout; } } diff -Nru logback-1.1.9/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java logback-1.2.3/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java --- logback-1.1.9/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java 2016-02-25 21:15:53.000000000 +0000 +++ logback-1.2.3/logback-examples/src/main/java/chapters/migrationFromLog4j/LogbackMain.java 2017-03-30 02:48:11.000000000 +0000 @@ -24,7 +24,7 @@ /** * A minimal application making use of logback-classic. It uses the * configuration file logback-trivial.xml which makes use of - * TivialLogbackAppender. + * TrivialLogbackAppender. * * @author Ceki Gülcü */ diff -Nru logback-1.1.9/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackAppender.java logback-1.2.3/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackAppender.java --- logback-1.1.9/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackAppender.java 2016-02-25 21:15:53.000000000 +0000 +++ logback-1.2.3/logback-examples/src/main/java/chapters/migrationFromLog4j/TrivialLogbackAppender.java 2017-03-30 02:48:11.000000000 +0000 @@ -13,48 +13,40 @@ */ package chapters.migrationFromLog4j; -import java.io.IOException; - -import ch.qos.logback.classic.encoder.PatternLayoutEncoder; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.AppenderBase; +import ch.qos.logback.core.Layout; public class TrivialLogbackAppender extends AppenderBase { - PatternLayoutEncoder encoder; - - public PatternLayoutEncoder getEncoder() { - return encoder; - } - - public void setEncoder(PatternLayoutEncoder encoder) { - this.encoder = encoder; - } + Layout layout; @Override public void start() { - if (this.encoder == null) { - addError("No encoder set for the appender named [" + name + "]."); + if (this.layout == null) { + addError("No layout set for the appender named [" + name + "]."); return; } - try { - encoder.init(System.out); - } catch (IOException e) { - } + String header = layout.getFileHeader(); + System.out.println(header); super.start(); } @Override - protected void append(ILoggingEvent loggingevent) { + protected void append(ILoggingEvent loggingEvent) { // note that AppenderBase.doAppend will invoke this method only if // this appender was successfully started. - try { - this.encoder.doEncode(loggingevent); - } catch (IOException e) { - // we can't do much with the exception except halting - super.stop(); - addError("Failed to write to the console"); - } + String eventAsStr = this.layout.doLayout(loggingEvent); + System.out.println(eventAsStr); + } + + + public Layout getLayout() { + return layout; + } + + public void setLayout(Layout layout) { + this.layout = layout; } } diff -Nru logback-1.1.9/logback-site/pom.xml logback-1.2.3/logback-site/pom.xml --- logback-1.1.9/logback-site/pom.xml 2017-01-20 18:37:25.000000000 +0000 +++ logback-1.2.3/logback-site/pom.xml 2017-04-01 03:15:20.000000000 +0000 @@ -7,7 +7,7 @@ ch.qos.logback logback-parent - 1.1.9 + 1.2.3 logback-site @@ -33,8 +33,17 @@ org.apache.maven.plugins maven-site-plugin - ${project.parent.basedir}/target/site - + ${project.parent.basedir}/target/site + + + + + org.apache.maven.plugins + maven-resources-plugin + + + js + diff -Nru logback-1.1.9/logback-site/src/site/pages/js/dsl.js logback-1.2.3/logback-site/src/site/pages/js/dsl.js --- logback-1.1.9/logback-site/src/site/pages/js/dsl.js 2016-02-10 21:53:10.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/js/dsl.js 2017-03-30 02:48:11.000000000 +0000 @@ -1,5 +1,5 @@ -var asGroovyURL='http://logback.qos.ch/translator/dsl/asGroovy'; +var asGroovyURL='https://logback.qos.ch/translator/dsl/asGroovy'; function asGroovy(id) { diff -Nru logback-1.1.9/logback-site/src/site/pages/manual/appenders.html logback-1.2.3/logback-site/src/site/pages/manual/appenders.html --- logback-1.1.9/logback-site/src/site/pages/manual/appenders.html 2016-03-30 18:43:42.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/manual/appenders.html 2017-03-30 02:48:11.000000000 +0000 @@ -272,7 +272,24 @@ underlying OutputStreamAppender. Encoders are described in a dedicated chapter. -
      + + + + + + + +
      '); +document.write(''); document.write(''); document.write('
      immediateFlushbooleanThe default value for immediateFlush is 'true'. Immediate + flushing of the output stream ensures that logging events are + immediately written out and will not be lost in case your + application exits without properly closing appenders. On the + other hand, setting this property to 'false' is likely to + quadruple (your mileage may vary) logging throughput. Again, if + immediateFlush is set to 'false' and + if appenders are not closed properly when your application exits, + then logging events not yet written to disk may be lost. +
      @@ -435,7 +452,6 @@

      - prudent @@ -509,11 +525,8 @@ events are not lost in case your application exits without properly closing appenders. However, for significantly increased logging throughput, you may want to set the immediateFlush property of the underlying - Encoder to false . Encoders and in - particular LayoutWrappingEncoder - are described in a separate chapter.

      + class="prop">immediateFlush property to + false.

      Below is an example of a configuration file for FileAppender: @@ -528,6 +541,8 @@ <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>testFile.log</file> <append>true</append> + <!-- set immediateFlush to false for much higher logging throughput --> + <immediateFlush>true</immediateFlush> <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> <encoder> diff -Nru logback-1.1.9/logback-site/src/site/pages/manual/configuration.html logback-1.2.3/logback-site/src/site/pages/manual/configuration.html --- logback-1.1.9/logback-site/src/site/pages/manual/configuration.html 2016-12-12 12:17:38.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/manual/configuration.html 2017-03-30 02:48:11.000000000 +0000 @@ -81,20 +81,21 @@

        +
      1. Logback tries to find a file called - logback.groovy logback-test.xml in the - classpath.

        -
      2. + classpath.

      3. -

        If no such file is found, logback tries to find a file - called logback-test.xml If no such file is found, logback tries to find a file called + logback.groovy in the classpath.

      4. +
      5. If no such file is found, it checks for the file logback.xml in the @@ -160,7 +161,7 @@ BasicConfigurator usage (logback-examples/src/main/java/chapters/configuration/MyApp1.java)

        -
        package manual.configuration;
        +    
        package chapters.configuration;
         
         import org.slf4j.Logger;
         import org.slf4j.LoggerFactory;
        @@ -778,8 +779,8 @@
            

        java -Dlogback.statusListenerClass=ch.qos.logback.core.status.NopStatusListener ...

        -

        Stopping - logback-classic

        +

        Stopping + logback-classic

        In order to release the resources used by logback-classic, it is always a good idea to stop the logback context. Stopping the @@ -800,7 +801,9 @@ the contextDestroyed method of ServletContextListener in order to stop - logback-classic and release resources. + logback-classic and release resources. Starting with version + 1.1.10, the appropriate ServletContextListener is + installed automatically for you (see just below).

        Stopping logback-classic @@ -823,8 +826,48 @@ can delay shutdown by a user specified duration. Note that you may install a shutdown hook of your own making by setting the class attribute to correspond to your shutdown - hook's class name.

        . + hook's class name.

        + +

        Stopping logback-classic + in web-applications

        + +

        since 1.1.10 Logback-classic will + automatically ask the web-server to install a LogbackServletContainerInitializer + implementing the ServletContainerInitializer interface + (available in servlet-api 3.x and later). This initializer will in + turn install and instance of LogbackServletContextListener. + This listener will stop the current logback-classic context when + the web-app is stopped or reloaded. +

        + +

        You may disable the automatic the installation of + LogbackServletContextListener by setting a + <context-param> named + logbackDisableServletContainerInitializer in your + web-application's web.xml file. Here is the relevant snippet.

        + + +
        <web-app>
        +    <context-param>
        +        <param-name>logbackDisableServletContainerInitializer</param-name>
        +        <param-value>true</param-value>
        +    </context-param>
        +    .... 
        +</web-app>
        + +

        Note that + logbackDisableServletContainerInitializer variable + can also be set as a Java system property an OS environment + variable. The most local setting has priority, i.e. web-app first, + system property second and OS environment last.

        + + + + +

        Configuration file syntax

        As you have seen thus far in the manual with plenty of examples @@ -1470,7 +1513,12 @@

        As they often come in handy, the HOSTNAME and CONTEXT_NAME - variables are automatically defined and have context scope.

        + variables are automatically defined and have context scope. Given + that in some environments it may take some time to compute the + hostname, its value is computed lazily (only when needed). Moreover, + HOSTNAME can be set from within the configuration directly. +

        Defining variables

        diff -Nru logback-1.1.9/logback-site/src/site/pages/manual/encoders.html logback-1.2.3/logback-site/src/site/pages/manual/encoders.html --- logback-1.1.9/logback-site/src/site/pages/manual/encoders.html 2015-04-06 17:06:08.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/manual/encoders.html 2017-03-30 02:48:11.000000000 +0000 @@ -142,13 +142,11 @@ protected Layout<E> layout; private Charset charset; - private boolean immediateFlush = true; - - public void doEncode(E event) throws IOException { - String txt = layout.doLayout(event); - outputStream.write(convertToBytes(txt)); - if (immediateFlush) - outputStream.flush(); + + // encode a given event as a byte[] + public byte[] encode(E event) { + String txt = layout.doLayout(event); + return convertToBytes(txt); } private byte[] convertToBytes(String s) { @@ -163,15 +161,7 @@

        The doEncode() method starts by having the wrapped layout convert the incoming event into string. The resulting text string is converted to bytes according to the charset encoding - chosen by the user. Those bytes are then written to the - OutputStream given by the owning appender. By - default, the OutputStream is immediately flushed, - unless the immediateFlush property is - explicitly set to 'false'. Setting the immediateFlush property to false can - significantly improve logging throughput. See - PatternLayoutEncoder below for sample configuration.. -

        + chosen by the user.

        PatternLayoutEncoder

        @@ -194,36 +184,9 @@

        immediateFlush property

        -

        As a sub-class of LayoutWrappingEncoder, - PatternLayoutEncoder admits the immediateFlush property. The default value - for immediateFlush is 'true'. Immediate - flushing of the output stream ensures that logging events are - immediately written to disk and will not be lost in case your - application exits without properly closing appenders. On the - other hand, setting this property to 'false' is likely to - quintuple (your mileage may vary) logging throughput. As - mentioned previously, if immediateFlush - is set to 'false' and if appenders are not closed properly when - your application exits, then logging events not yet written to - disk may be lost. -

        - -

        Below is a sample configuration for a - FileAppender containing a - PatternLayoutEncoder with its immediateFlush property set to 'false'.

        - -
        <appender name="FILE" class="ch.qos.logback.core.FileAppender"> 
        -  <file>foo.log</file>
        -  <encoder>
        -    <pattern>%d %-5level [%thread] %logger{0}: %msg%n</pattern>
        -    <!-- this quadruples logging throughput -->
        -    <immediateFlush>false</immediateFlush>
        -  </encoder> 
        -</appender>
        - +

        As of logback 1.2.0, the + immediateFlush property is part of the + enclosing Appender.

        Output pattern string as header

        diff -Nru logback-1.1.9/logback-site/src/site/pages/manual/layouts.html logback-1.2.3/logback-site/src/site/pages/manual/layouts.html --- logback-1.1.9/logback-site/src/site/pages/manual/layouts.html 2016-03-30 18:43:42.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/manual/layouts.html 2017-03-30 02:48:11.000000000 +0000 @@ -819,7 +819,8 @@ full stack trace will be output.

        -

        The throwable conversion word can followed by one of + +

        The throwable conversion word can followed by one of the following options:

          @@ -870,6 +871,17 @@ negative answer. Evaluators are described further down in this document.

          + +

          If you do not specify %throwable or another + throwable-related conversion word in the conversion pattern, + PatternLayout will automatically add it as the + last conversion word, on account of the importance of stack + trace information. The $nopex conversion word can be + substituted for %throwable, if you do not wish stack trace + information to be displayed. See also the %nopex conversion + word. +

          + @@ -888,16 +900,6 @@

          Same as the %throwable conversion word above with the addition of class packaging information.

          -

          If you do not specify %xThrowable or another - throwable-related conversion word in the conversion pattern, - PatternLayout will automatically add it as the - last conversion word, on account of the importance of stack - trace information. The $nopex conversion word can be - substituted for %xThrowable, if you do not wish stack - trace information to be displayed. See also the %nopex - conversion word. -

          -

          At the end of each stack frame of the exception, a string consisting of the jar file containing the relevant class followed by the "Implementation-Version" as found in that @@ -934,15 +936,18 @@ by a tilde, it is possible that the correct packaging data is in reality [wombat.jar:1.7].

          - + +

          Please note that given its potential cost, computation of + packaging data + is disabled by default. When computation of + packaging data is enabled, PatternLayout will + automatically assume the %xThrowable suffix instead of + %throwable suffix at the end of the pattern string.

          +

          Feedback from users indicates that Netbeans chokes on packaging - information. If you are a Netbeans user, then you should - disable packaging information in stack traces by adding - "%ex" at the end of of your conversion pattern. For example, - "%d %logger - %m%n" should be rewritten as "%d %logger - - %m%n%ex" + information.

          diff -Nru logback-1.1.9/logback-site/src/site/pages/manual/mdc.html logback-1.2.3/logback-site/src/site/pages/manual/mdc.html --- logback-1.1.9/logback-site/src/site/pages/manual/mdc.html 2015-04-06 17:07:03.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/manual/mdc.html 2017-03-30 02:48:11.000000000 +0000 @@ -89,18 +89,18 @@ lets the developer place information in a diagnostic context that can be subsequently retrieved by certain logback components. The MDC manages contextual information on - a per thread basis. A child thread automatically - inherits a copy of the mapped diagnostic context of its - parent. Typically, while starting to service a new client request, - the developer will insert pertinent contextual information, such - as the client id, client's IP address, request parameters - etc. into the MDC. Logback components, if - appropriately configured, will automatically include this - information in each log entry. + a per thread basis. Typically, while starting to service + a new client request, the developer will insert pertinent + contextual information, such as the client id, client's IP + address, request parameters etc. into the + MDC. Logback components, if appropriately configured, + will automatically include this information in each log entry.

          Please note that MDC as implemented by logback-classic assumes - that values are placed into the MDC with moderate frequency.

          + that values are placed into the MDC with moderate frequency. Also + note that a child thread does not automatically inherit a copy of + the mapped diagnostic context of its parent.

          The next application named diff -Nru logback-1.1.9/logback-site/src/site/pages/news.html logback-1.2.3/logback-site/src/site/pages/news.html --- logback-1.1.9/logback-site/src/site/pages/news.html 2017-01-20 18:38:20.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/news.html 2017-04-01 03:14:25.000000000 +0000 @@ -30,11 +30,201 @@ the QOS.ch announce mailing list.

          + +
          -

          January 20th, 2017, Release of version 1.1.9

          +

          March 30th, 2017, Release of version 1.2.3

          + +

          Fix unintentional dependency on + OutputStreamAppender in + LayoutWrappingEncoder as reported in LOGBACK-1287. +

          + +

          Fix spurious System.out.println in AsyncAppender's + worker thread. This issue was reported in LOGBACK-1292 by + Nikolas Loutas with Thibault Meyer the relevant patch.

          + +

          ConsoleAppender exception when run under Java WebStart. This + problem was reported in LOGBACK-1282 by + Clas Forsberg.

          + +

          March 16th, 2017, Release of version 1.2.2

          + +

          AsyncAppender no longer drops events when the + current thread has its interrupt flag set. This issue was reported + in LOGBACK-1247 by + Jakob Bergendahl who also provided the relevant pull request. +

          + +

          Removed JMSQueueAppender and + JMSTopicAppender. These appenders were undocumented + and had no apparent users.

          + +

          Remove comment in logback-classic's + META-INF/services/javax.servlet.ServletContainerInitializer + file in order to keep Wildfly 8 happy. This issue was reported in + LOGBACK-1265 + by Andy Wilkinson. +

          + +

          FileSize.toString() now reports files sizes in GB + in addition to sizes in MB and KB and Bytes. This fixes issue LOGBACK-1278.

          + +
          + +

          March 1st, 2017, Release of version 1.1.11

          + +

          Fix thread-safety issue with PatternLayoutBase + reported in LOGBACK-1270 by + Artem Bilan. Note that the fix was already present in the 1.2.x + series and was back-ported to the 1.1.x series.

          + +
          + +

          February 9th, 2017, Release of version 1.2.1

          + +

          To ensure backward compatibility of configuration files, the + immediateFlush property set for a + LayoutWrappingEncoder is propagated to the enclosing + OutputStreamAppender. +

          + +
          + +

          February 8th, 2017, Release of version 1.2.0

          + +
          +

          Encoder interface has changed and is no longer + expected to handle an OutputStream.

          +
          + +

          Encoder interface has changed and is no longer + expected to handle an OutputStream. This + simplification allows finer-grain locking resulting in significantly + improved performance. +

          + +

          Release 1.2.0 fixes a rather severe + serialization vulnerability in SocketServer and + ServerSocketReceiver. Users running these components + should upgrade immediately.

          + + +

          This release fixes a rather severe serialization vulnerability + in SocketServer and + ServerSocketReceiver. Users running these components + should upgrade immediately. +

          + +

          In TimeBasedRollingPolicy, fixed issue with totalSizeCap of more than 2^31. This problem + was reported in 1231 by Simon + Teng. +

          + +

          Logback-classic now searches for the file + logback-test.xml first, logback.groovy second + and logback.xml third. In previous versions + logback.groovy was looked up first which was non-sensical + in presense of logback-test.xml. This fixes LOGBACK-1245 + reported by Joern Huxhorn. +

          + + +
          + +

          February 5th, 2017, Release of version 1.1.10

          + +

          Several changes to improve throughput (see spreadsheet) +

          + +
            +
          1. The ReentrantLock in + OutputStreamAppender is now "unfair". In previous + versions of logback, a fair lock was used. Fair locks are much + slower. Just as importanly, logback has no mandate to influence + thread scheduling. +
          2. + +
          3. FileAppender now offers the bufferSize option. Previously, a + fixed-size 8K buffer was used. Increasing the bufferSize, for example to 256K, + significantly reduces thread-contention. +
          4. + +
          5. Critical parts of the code now use + COWArrayList, a custom developed allocation-free + lock-free thread-safe implementation of the {@link List} + interface. It is optimized for cases where iterations over the + list vastly outnumber modifications on the list. It is based on + CopyOnWriteArrayList but allows allocation-free + iterations over the list. +
          6. + +
          7. In PatternLayoutBase the same + StringBuilder is used over and over to reduce + memory allocation. This is safe as long as the owning appender + guarantees serial access to its layout. In the next version of + logback, i.e. 1.2.x, the read-write lock will no longer protect + access to the layout and there will be no guarantee of + serial access. +
          8. +
          + +

          In web-applications, logback-classic will automatically + install a listener which will stop the logging context and + release resources when your web-app is reloaded. This enhancement + was requested LOGBACK-1170 by + Martin Wegner. +

          + +

          The AccessEvent.prepareForDeferredProcessing() + method was not idempotent. This caused subtle bugs under + Jetty. See LOGBACK-1189 + for details. Many thanks to Per Olesen, Evan Meagher, Nick Babcock + and Mark Elliot for hunting down this bug. +

          + +

          As it may be time consuming in certain environments, the + HOSTNAME property is now computed lazily. This optimization + requested in LOGBACK-1221 by + Eugene Petrenko. +

          + + +

          Joran now supports external XML entities. This feature was + requested in 1091 and the + relevant PR graciously provided by Jonas Neukomm. +

          + +
          + +

          January 20th, 2017, Release of version 1.1.9

          Logback's internal executor service had a thread pool size of 2 which could be used up rather quickly, e.g. configuration scanning diff -Nru logback-1.1.9/logback-site/src/site/pages/setup.html logback-1.2.3/logback-site/src/site/pages/setup.html --- logback-1.1.9/logback-site/src/site/pages/setup.html 2016-03-31 12:57:56.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/setup.html 2017-03-30 02:48:12.000000000 +0000 @@ -107,6 +107,8 @@ <version>${project.version}</version> </dependency>

        + + <!-- Look mom, no version! --> </dependency>
        + --> +

        Optional dependencies

        SMTPAppender requires @@ -257,7 +261,7 @@ Root directory. The import should finish successfully in a few seconds.

        -

        Building with Eclipse

        +

        Building with Eclipse and "mvn eclipse:eclipse"

        Building logback under Eclipse is a little trickier. Here are instructions for building logback under Eclipse using the maven @@ -276,13 +280,7 @@

          -
        1. Install Eclipse
        2. - - - -
        3. Install the Groovy plugin for Eclipse. +
        4. Ensure that the Groovy plugin for Eclipse is installed.
          • @@ -297,9 +295,7 @@
          • In Eclipse, select Help → Intall new Software → Work with the update site you chose in the previous step and - then Select "Groovy-Eclipse Feature". Installation of other - plugins in particular "m2e Configurator for Groovy-Eclipse" - is not necessary + then Select "Groovy-Eclipse Feature".
        5. @@ -318,30 +314,7 @@
        6. In Eclipse, import the logback project: Import→ General→ Existing Projects into Workspace, select $LOGBACK_HOME folder for the import -
        7. - - - - +
        8. In Eclipse, clean all projects in Eclipse (Project → Clean) @@ -356,13 +329,90 @@

          The above listed procedure has been last tested by the author - using Eclipse Luna on February 25th, 2016.

          + using Eclipse Neon on March 17th, 2017.

          + +

          Building with Eclipse+m2eclipse

          + +

          Building with Eclipse and m2eclipse is a bit more complicated + due to the use of Groovy in logback-classic. +

          + +

          Here are the required steps:

          + + +
            +
          1. Ensure that the Groovy plugin for Eclipse is installed. See + above for instructions.
          2. + +
          3. In Eclipse, import the logback project: Import→ + Maven→ Existing Maven Projects, select + $LOGBACK_HOME folder for the import +
          4. + +
          5. Install any discovered m2e connections, + e.g. "maven-bundle-plugin". +

            + + Click to enlarge + +

            + +

            You may need to restart Eclipse.

            . + +
          6. + +
          7. In Eclipse, select logback-classic project and check that it + has "Groovy" nature. If not add it by right clicking on + logback-classic project → Groovy → Convert Groovy to + Project. +
          8. + +
          9. At this stage Eclipse may complain about + GafferConfigurator not being resolved. To fix these + errors, select logback-classic project properties, select "Java + Build Path" → Source → "logback-classic/src/main/groovy". + Select "Excluded" and then click on Remove. + +

            + + Click to enlarge + +

            + +
          10. + +
          11. +

            Project → Clean → Clean all projects.

            +
          12. + +
          13. To fix the errors in the logback-examples project, you need + to instruct logback-classic to not export its Maven dependencies. + Select logback-classic project properties, select "Java + Build Path" → Order and Export and deselect "Maven Dependencies". + +

            + + Click to enlarge + +

            +
          14. + +
          15. +

            Project → Clean → Clean all projects.

            +
          16. + + + +
          + + + -

          Call for volunteers Given that many - users prefer M2Eclipse for building projects under Eclipse IDE, we - are looking for volunteers to help work out the steps for building - logback with M2Eclipse. +

          Call for volunteers Given that + many users prefer M2Eclipse for building projects under Eclipse + IDE, we are looking for volunteers to help simplify the steps + required for building logback with M2Eclipse.

          diff -Nru logback-1.1.9/logback-site/src/site/pages/templates/creative.js logback-1.2.3/logback-site/src/site/pages/templates/creative.js --- logback-1.1.9/logback-site/src/site/pages/templates/creative.js 2016-03-29 14:04:46.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/templates/creative.js 2017-03-30 02:48:12.000000000 +0000 @@ -5,14 +5,14 @@ document.write('

          '); document.write(' Authors: Ceki Gülcü, Sébastien Pennec, Carl Harris'); document.write('
          '); -document.write(' Copyright © 2000-2016, QOS.ch

          '); +document.write(' Copyright © 2000-2017, QOS.ch

          '); document.write(' '); document.write(' '); document.write(' '); document.write(' Creative Commons License'); +document.write(' src="https://creativecommons.org/images/public/somerights20.png" />'); document.write(' '); document.write(' '); document.write(' '); diff -Nru logback-1.1.9/logback-site/src/site/pages/templates/footer.js logback-1.2.3/logback-site/src/site/pages/templates/footer.js --- logback-1.1.9/logback-site/src/site/pages/templates/footer.js 2017-01-06 21:09:07.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/templates/footer.js 2017-03-30 02:48:12.000000000 +0000 @@ -7,7 +7,7 @@ document.write(' '); document.write(' '); -document.write(' Follow @qos_ch'); +document.write(' Follow @qos_ch'); document.write(' '); document.write(' '); diff -Nru logback-1.1.9/logback-site/src/site/pages/templates/header.js logback-1.2.3/logback-site/src/site/pages/templates/header.js --- logback-1.1.9/logback-site/src/site/pages/templates/header.js 2013-03-12 15:33:25.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/templates/header.js 2017-03-30 02:48:12.000000000 +0000 @@ -1,5 +1,5 @@ document.write(''); -document.write('') diff -Nru logback-1.1.9/logback-site/src/site/pages/templates/left.js logback-1.2.3/logback-site/src/site/pages/templates/left.js --- logback-1.1.9/logback-site/src/site/pages/templates/left.js 2016-11-25 16:49:50.000000000 +0000 +++ logback-1.2.3/logback-site/src/site/pages/templates/left.js 2017-03-30 02:48:12.000000000 +0000 @@ -20,8 +20,8 @@ document.write(''); -document.write(''); document.write(''); @@ -30,7 +30,7 @@ document.write(''); Binary files /tmp/tmp_w3zLB/z9ana35gcZ/logback-1.1.9/logback-site/src/site/resources/images/setup/deselectMavenDependenciesExport.png and /tmp/tmp_w3zLB/lmaIvID0_A/logback-1.2.3/logback-site/src/site/resources/images/setup/deselectMavenDependenciesExport.png differ Binary files /tmp/tmp_w3zLB/z9ana35gcZ/logback-1.1.9/logback-site/src/site/resources/images/setup/discoverM2EConnectors.png and /tmp/tmp_w3zLB/lmaIvID0_A/logback-1.2.3/logback-site/src/site/resources/images/setup/discoverM2EConnectors.png differ Binary files /tmp/tmp_w3zLB/z9ana35gcZ/logback-1.1.9/logback-site/src/site/resources/images/setup/removeGroovyExclusions.png and /tmp/tmp_w3zLB/lmaIvID0_A/logback-1.2.3/logback-site/src/site/resources/images/setup/removeGroovyExclusions.png differ diff -Nru logback-1.1.9/pom.xml logback-1.2.3/pom.xml --- logback-1.1.9/pom.xml 2017-01-20 18:48:32.000000000 +0000 +++ logback-1.2.3/pom.xml 2017-04-01 03:15:20.000000000 +0000 @@ -1,3 +1,4 @@ + @@ -6,7 +7,7 @@ ch.qos.logback logback-parent - 1.1.9 + 1.2.3 pom Logback-Parent @@ -51,19 +52,23 @@ UTF-8 4.10 1.4 - 2.7.8 + 3.0.6 2.4.0 - 1.7.22 + 1.7.25 + 0.8.1 1.1.0 - 7.0.59 - 7.5.1.v20110908 + + 8.5.9 + + 8.2.0.v20160908 + 1.9 - 2.9.1 - 2.6 - 1.9.0 + 2.10.4 + 2.7 + 3.0 @@ -152,9 +157,9 @@ 1.6.1 - hsqldb + org.hsqldb hsqldb - 1.8.0.7 + 2.3.4 com.h2database @@ -186,21 +191,24 @@ jetty-server ${jetty.version} - - org.apache.geronimo.specs - geronimo-jms_1.1_spec - 1.0 - + javax.servlet - servlet-api - 2.5 + javax.servlet-api + 3.1.0 + joda-time joda-time 2.9.2 + + + org.mockito + mockito-core + 2.7.9 + @@ -210,7 +218,7 @@ org.apache.maven.wagon wagon-ssh - 2.8 + 2.10 @@ -219,12 +227,12 @@ org.apache.maven.plugins maven-clean-plugin - 2.6.1 + 3.0.0 org.apache.maven.plugins maven-compiler-plugin - 3.5.1 + 3.6.0 org.apache.maven.plugins @@ -239,12 +247,12 @@ org.apache.maven.plugins maven-resources-plugin - 2.6 + 3.0.1 org.apache.maven.plugins maven-site-plugin - 3.4 + 3.6 org.apache.maven.plugins @@ -254,7 +262,7 @@ org.apache.maven.plugins maven-jar-plugin - 2.5 + 2.6 org.apache.maven.plugins @@ -269,28 +277,28 @@ org.apache.maven.plugins maven-release-plugin - 2.5.1 + 2.5.3 org.apache.maven.plugins maven-source-plugin - 2.4 + 3.0.1 org.codehaus.mojo findbugs-maven-plugin - 3.0.0 + 3.0.4 org.apache.felix maven-bundle-plugin - 2.5.3 + 2.5.4 org.codehaus.mojo animal-sniffer-maven-plugin - 1.14 + 1.15 sun.reflect.Reflection @@ -325,7 +333,7 @@ org.apache.maven.plugins maven-assembly-plugin - 2.5.3 + 3.0.0 src/main/assembly/dist.xml @@ -370,7 +378,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.1 + 2.10.4 true true @@ -440,9 +448,9 @@ - com.mycila.maven-license-plugin - maven-license-plugin - 1.9.0 + com.mycila + license-maven-plugin + ${maven-license-plugin.version}
          src/main/licenseHeader.txt
          false diff -Nru logback-1.1.9/README.md logback-1.2.3/README.md --- logback-1.1.9/README.md 1970-01-01 00:00:00.000000000 +0000 +++ logback-1.2.3/README.md 2017-03-30 02:48:09.000000000 +0000 @@ -0,0 +1,57 @@ + +#About logback + +Thank you for your interest in logback, the reliable, generic, fast +and flexible logging library for Java. + +The Logback documentation can be found on the [project +web-site](https://logback.qos.ch/documentation.html) as well as under +the docs/ folder of the logback distribution. + +#Building logback + +Building logback is documented at: + + https://logback.qos.ch/setup.html#ide + +#In case of problems + +In case of problems please do not hesitate to post an e-mail message +on the logback-user@qos.ch mailing list. However, please do not +directly e-mail logback developers. The answer to your question might +be useful to other users. Moreover, there are many knowledgeable users +on the logback-user mailing lists who can quickly answer your +questions. + + +#Pull requests + +If you are interested in improving logback, great! The logback community +looks forward to your contribution. Please follow this process: + +1. Please file a [bug + report](https://logback.qos.ch/bugreport.html). Pull requests with + an associated JIRA issue will get more attention. + + Optional: Start a discussion on the [logback-dev mailing + list](https://logback.qos.ch/mailinglist.html) about your proposed + change. + +2. Fork qos-ch/logback. Ideally, create a new branch from your fork for + your contribution to make it easier to merge your changes back. + +3. Make your changes on the branch you hopefuly created in Step 2. Be + sure that your code passes existing unit tests. + +4. Please add unit tests for your work if appropriate. It usually is. + +5. Push your changes to your fork/branch in github. Don't push it to + your master! If you do it will make it harder to submit new changes + later. + +6. Submit a pull request to logback from from your commit page on + github. + + +# Build Status +[![Build Status](https://travis-ci.org/qos-ch/slf4j.png)](https://travis-ci.org/qos-ch/slf4j) diff -Nru logback-1.1.9/README.txt logback-1.2.3/README.txt --- logback-1.1.9/README.txt 2016-12-09 11:57:44.000000000 +0000 +++ logback-1.2.3/README.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -Thank you for downloading logback, the reliable, generic, fast and -flexible logging library for Java. - -The Logback documentation can be found under the docs/ directory. - -Building logback -================ - -Building logback is documented at: - - http://logback.qos.ch/setup.html#ide - -In case of problems -=================== - -In case of problems please do not hesitate to post an e-mail message -on the logback-user@qos.ch mailing list. However, please do not -directly e-mail logback developers. The answer to your question might -be useful to other users. Moreover, there are many knowledgeable users -on the logback-user mailing lists who can quickly answer your -questions. diff -Nru logback-1.1.9/src/main/assembly/dist.xml logback-1.2.3/src/main/assembly/dist.xml --- logback-1.1.9/src/main/assembly/dist.xml 2016-12-12 12:17:38.000000000 +0000 +++ logback-1.2.3/src/main/assembly/dist.xml 2017-03-30 02:48:12.000000000 +0000 @@ -136,21 +136,21 @@ logback-core/target/ - / + ./ logback-core-${project.version}.jar logback-classic/target/ - / + ./ logback-classic-${project.version}.jar logback-access/target/ - / + ./ logback-access-${project.version}.jar @@ -158,21 +158,21 @@ logback-core/target/ - / + ./ logback-core-${project.version}-sources.jar logback-classic/target/ - / + ./ logback-classic-${project.version}-sources.jar logback-access/target/ - / + ./ logback-access-${project.version}-sources.jar diff -Nru logback-1.1.9/src/main/clas/signed-clas.txt logback-1.2.3/src/main/clas/signed-clas.txt --- logback-1.1.9/src/main/clas/signed-clas.txt 2017-01-06 21:15:01.000000000 +0000 +++ logback-1.2.3/src/main/clas/signed-clas.txt 2017-03-30 02:48:12.000000000 +0000 @@ -51,6 +51,8 @@ Kenneth Gendron CA, USA 2016-04-01 Espen A. Fossen Norway 2016-04-07 Scott Babcock WA, USA 2016-12-22 +Olivier Bourgain France 2017-01-31 +Nicolas Maupu France 2017-01-31 Justification for CLAs ----------------------
          '); +document.write(''); document.write(''); document.write('