From 6bf860358540df4976e28505fad9ff1b9b0e5ee0 Mon Sep 17 00:00:00 2001
From: jon-ruckwood
Date: Fri, 26 Aug 2011 15:03:04 +0100
Subject: [PATCH 001/260] Fixed an issue where an extra line of the stack trace
was being printed by the ThrowableProxyConverter when specifying a length
option.
---
.../pattern/ThrowableProxyConverter.java | 5 +-
.../pattern/ThrowableProxyConverterTest.java | 52 +++++++++++++++++--
2 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java
index 0a68cf820..7ac49dc12 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java
@@ -51,11 +51,10 @@ public class ThrowableProxyConverter extends ThrowableHandlingConverter {
if ("full".equals(lengthStr)) {
lengthOption = Integer.MAX_VALUE;
} else if ("short".equals(lengthStr)) {
- lengthOption = 2;
+ lengthOption = 1;
} else {
try {
- // we add one because, printing starts at offset 1
- lengthOption = Integer.parseInt(lengthStr) + 1;
+ lengthOption = Integer.parseInt(lengthStr);
} catch (NumberFormatException nfe) {
addError("Could not parser [" + lengthStr + " as an integer");
lengthOption = Integer.MAX_VALUE;
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java
index cbe18df38..88852e495 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java
@@ -13,10 +13,12 @@
*/
package ch.qos.logback.classic.pattern;
-import static org.junit.Assert.assertEquals;
-
+import java.io.BufferedReader;
import java.io.PrintWriter;
+import java.io.StringReader;
import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.List;
import org.junit.After;
import org.junit.Before;
@@ -29,6 +31,8 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.classic.util.TeztHelper;
+import static org.junit.Assert.*;
+
public class ThrowableProxyConverterTest {
LoggerContext lc = new LoggerContext();
@@ -65,6 +69,48 @@ public class ThrowableProxyConverterTest {
verify(t);
}
+ @Test
+ public void withArgumentOfOne() throws Exception {
+ // given
+ final Throwable t = TeztHelper.makeNestedException(0);
+ t.printStackTrace(pw);
+ final ILoggingEvent le = createLoggingEvent(t);
+
+ final List optionList = Arrays.asList("1");
+ tpc.setOptionList(optionList);
+ tpc.start();
+
+ // when
+ final String result = tpc.convert(le);
+
+ // then
+ final BufferedReader reader = new BufferedReader(new StringReader(result));
+ assertTrue(reader.readLine().contains(t.getMessage()));
+ assertNotNull(reader.readLine());
+ assertNull("Unexpected line in stack trace", reader.readLine());
+ }
+
+ @Test
+ public void withShortArgument() throws Exception {
+ // given
+ final Throwable t = TeztHelper.makeNestedException(0);
+ t.printStackTrace(pw);
+ final ILoggingEvent le = createLoggingEvent(t);
+
+ final List options = Arrays.asList("short");
+ tpc.setOptionList(options);
+ tpc.start();
+
+ // when
+ final String result = tpc.convert(le);
+
+ // then
+ final BufferedReader reader = new BufferedReader(new StringReader(result));
+ assertTrue(reader.readLine().contains(t.getMessage()));
+ assertNotNull(reader.readLine());
+ assertNull("Unexpected line in stack trace", reader.readLine());
+ }
+
void verify(Throwable t) {
t.printStackTrace(pw);
@@ -74,6 +120,4 @@ public class ThrowableProxyConverterTest {
result = result.replace("common frames omitted", "more");
assertEquals(sw.toString(), result);
}
-
-
}
--
GitLab
From a71fad16ed5cd9174d599f524e26056186f68657 Mon Sep 17 00:00:00 2001
From: jon-ruckwood
Date: Fri, 26 Aug 2011 15:33:58 +0100
Subject: [PATCH 002/260] Removed the given/when/then comments, as they're not
in keeping with existing tests.
---
.../classic/pattern/ThrowableProxyConverterTest.java | 6 ------
1 file changed, 6 deletions(-)
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java
index 88852e495..bf0fdd4f8 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java
@@ -71,7 +71,6 @@ public class ThrowableProxyConverterTest {
@Test
public void withArgumentOfOne() throws Exception {
- // given
final Throwable t = TeztHelper.makeNestedException(0);
t.printStackTrace(pw);
final ILoggingEvent le = createLoggingEvent(t);
@@ -80,10 +79,8 @@ public class ThrowableProxyConverterTest {
tpc.setOptionList(optionList);
tpc.start();
- // when
final String result = tpc.convert(le);
- // then
final BufferedReader reader = new BufferedReader(new StringReader(result));
assertTrue(reader.readLine().contains(t.getMessage()));
assertNotNull(reader.readLine());
@@ -92,7 +89,6 @@ public class ThrowableProxyConverterTest {
@Test
public void withShortArgument() throws Exception {
- // given
final Throwable t = TeztHelper.makeNestedException(0);
t.printStackTrace(pw);
final ILoggingEvent le = createLoggingEvent(t);
@@ -101,10 +97,8 @@ public class ThrowableProxyConverterTest {
tpc.setOptionList(options);
tpc.start();
- // when
final String result = tpc.convert(le);
- // then
final BufferedReader reader = new BufferedReader(new StringReader(result));
assertTrue(reader.readLine().contains(t.getMessage()));
assertNotNull(reader.readLine());
--
GitLab
From eb5b84b31dd1bc06526b4f94be86981977efc676 Mon Sep 17 00:00:00 2001
From: Lingo
Date: Tue, 7 Aug 2012 00:26:35 +0800
Subject: [PATCH 003/260] add ResourceExistsPropertyDefiner
---
.../ResourceExistsPropertyDefiner.java | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/property/ResourceExistsPropertyDefiner.java
diff --git a/logback-core/src/main/java/ch/qos/logback/core/property/ResourceExistsPropertyDefiner.java b/logback-core/src/main/java/ch/qos/logback/core/property/ResourceExistsPropertyDefiner.java
new file mode 100644
index 000000000..f18adf5ca
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/property/ResourceExistsPropertyDefiner.java
@@ -0,0 +1,31 @@
+package ch.qos.logback.core.property;
+
+import java.net.URL;
+
+import ch.qos.logback.core.PropertyDefinerBase;
+import ch.qos.logback.core.util.Loader;
+
+/**
+ * @author XuHuisheng
+ */
+public class ResourceExistsPropertyDefiner extends PropertyDefinerBase {
+
+ String path;
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getPropertyValue() {
+ if(path == null)
+ return "false";
+
+ URL resourceURL = Loader.getResourceBySelfClassLoader(path);
+
+ return (resourceURL != null) ? "true" : "false";
+ }
+}
--
GitLab
From 86a60af62a0bb1b25c20bac634171fdff5ca8154 Mon Sep 17 00:00:00 2001
From: Pasi Eronen
Date: Fri, 31 Aug 2012 16:27:34 +0300
Subject: [PATCH 004/260] truncate instead of discard too long syslog messages
(fixes LOGBACK-141)
---
.../logback/core/net/SyslogAppenderBase.java | 25 ++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SyslogAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SyslogAppenderBase.java
index ee6b3ac55..cd29d433e 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/SyslogAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/SyslogAppenderBase.java
@@ -33,7 +33,6 @@ public abstract class SyslogAppenderBase extends AppenderBase {
final static String SYSLOG_LAYOUT_URL = CoreConstants.CODES_URL
+ "#syslog_layout";
- final static int MSG_SIZE_LIMIT = 256 * 1024;
Layout layout;
String facilityStr;
@@ -41,6 +40,7 @@ public abstract class SyslogAppenderBase extends AppenderBase {
protected String suffixPattern;
SyslogOutputStream sos;
int port = SyslogConstants.SYSLOG_PORT;
+ int maxMessageSize = 65000;
public void start() {
int errorCount = 0;
@@ -84,8 +84,8 @@ public abstract class SyslogAppenderBase extends AppenderBase {
if(msg == null) {
return;
}
- if (msg.length() > MSG_SIZE_LIMIT) {
- msg = msg.substring(0, MSG_SIZE_LIMIT);
+ if (msg.length() > maxMessageSize) {
+ msg = msg.substring(0, maxMessageSize);
}
sos.write(msg.getBytes());
sos.flush();
@@ -211,6 +211,25 @@ public abstract class SyslogAppenderBase extends AppenderBase {
this.port = port;
}
+ /**
+ *
+ * @return
+ */
+ public int getMaxMessageSize() {
+ return maxMessageSize;
+ }
+
+ /**
+ * Maximum size for the syslog message (in characters); messages
+ * longer than this are truncated. The default value is 65400 (which
+ * is near the maximum for syslog-over-UDP). Note that the value is
+ * characters; the number of bytes may vary if non-ASCII characters
+ * are present.
+ */
+ public void setMaxMessageSize(int maxMessageSize) {
+ this.maxMessageSize = maxMessageSize;
+ }
+
public Layout getLayout() {
return layout;
}
--
GitLab
From 29427d18c8fe26ca97d2418ce25580df764e8bb8 Mon Sep 17 00:00:00 2001
From: Pasi Eronen
Date: Fri, 31 Aug 2012 16:32:59 +0300
Subject: [PATCH 005/260] updated test case for large syslog messages
(LOGBACK-141)
---
.../classic/net/SyslogAppenderTest.java | 23 +++++++++++++------
.../classic/net/mock/MockSyslogServer.java | 2 +-
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java
index c2afe5b55..86870fa57 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java
@@ -148,7 +148,7 @@ public class SyslogAppenderTest {
@Test
public void large() throws InterruptedException {
- setMockServerAndConfigure(1);
+ setMockServerAndConfigure(2);
StringBuilder largeBuf = new StringBuilder();
for (int i = 0; i < 2 * 1024 * 1024; i++) {
largeBuf.append('a');
@@ -162,15 +162,24 @@ public class SyslogAppenderTest {
mockServer.join(8000);
assertTrue(mockServer.isFinished());
-
- // the first message is wasted
- assertEquals(1, mockServer.getMessageList().size());
- String msg = mockServer.getMessageList().get(0);
- String expected = "<"
+
+ // both messages received
+ assertEquals(2, mockServer.getMessageList().size());
+
+ String expected = "<"
+ (SyslogConstants.LOG_MAIL + SyslogConstants.DEBUG_SEVERITY) + ">";
- assertTrue(msg.startsWith(expected));
String expectedPrefix = "<\\d{2}>\\w{3} \\d{2} \\d{2}(:\\d{2}){2} [\\w.-]* ";
String threadName = Thread.currentThread().getName();
+
+ // large message is truncated
+ String largeMsg = mockServer.getMessageList().get(0);
+ assertTrue(largeMsg.startsWith(expected));
+ String largeRegex = expectedPrefix + "\\[" + threadName + "\\] " + loggerName
+ + " " + "a{64000,66000}";
+ checkRegexMatch(largeMsg, largeRegex);
+
+ String msg = mockServer.getMessageList().get(1);
+ assertTrue(msg.startsWith(expected));
String regex = expectedPrefix + "\\[" + threadName + "\\] " + loggerName
+ " " + logMsg;
checkRegexMatch(msg, regex);
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockSyslogServer.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockSyslogServer.java
index a0bd6a64f..95b3dd289 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockSyslogServer.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/mock/MockSyslogServer.java
@@ -44,7 +44,7 @@ public class MockSyslogServer extends Thread {
socket = new DatagramSocket(port);
for (int i = 0; i < loopLen; i++) {
- byte[] buf = new byte[2048];
+ byte[] buf = new byte[65536];
DatagramPacket packet = new DatagramPacket(buf, buf.length);
//System.out.println("Waiting for message");
socket.receive(packet);
--
GitLab
From 6be188ac67a9754405cafb5496afc8028604ad0f Mon Sep 17 00:00:00 2001
From: Tomasz Nurkiewicz
Date: Fri, 29 Mar 2013 15:48:37 +0100
Subject: [PATCH 006/260] Introducing AbstractDiscriminator base class to avoid
repeated start()/stop() implementation in each concrete Discriminator
---
.../access/sift/AccessEventDiscriminator.java | 17 +++---------
.../sift/ContextBasedDiscriminator.java | 19 ++------------
.../sift/JNDIBasedContextDiscriminator.java | 19 ++------------
.../classic/sift/MDCBasedDiscriminator.java | 16 +++---------
.../core/sift/AbstractDiscriminator.java | 26 +++++++++++++++++++
.../core/sift/DefaultDiscriminator.java | 16 +-----------
6 files changed, 37 insertions(+), 76 deletions(-)
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/sift/AbstractDiscriminator.java
diff --git a/logback-access/src/main/java/ch/qos/logback/access/sift/AccessEventDiscriminator.java b/logback-access/src/main/java/ch/qos/logback/access/sift/AccessEventDiscriminator.java
index 46bd1e4f0..1cefb7640 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/sift/AccessEventDiscriminator.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/sift/AccessEventDiscriminator.java
@@ -17,8 +17,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import ch.qos.logback.access.spi.IAccessEvent;
-import ch.qos.logback.core.sift.Discriminator;
-import ch.qos.logback.core.spi.ContextAwareBase;
+import ch.qos.logback.core.sift.AbstractDiscriminator;
/**
*
@@ -30,10 +29,7 @@ import ch.qos.logback.core.spi.ContextAwareBase;
* @author Ceki Gülcü
*
*/
-public class AccessEventDiscriminator extends ContextAwareBase implements
- Discriminator {
-
- boolean started = false;
+public class AccessEventDiscriminator extends AbstractDiscriminator {
/**
* At present time the followed fields can be designated: COOKIE,
@@ -120,10 +116,7 @@ public class AccessEventDiscriminator extends ContextAwareBase implements
return null;
}
- public boolean isStarted() {
- return started;
- }
-
+ @Override
public void start() {
int errorCount = 0;
@@ -152,10 +145,6 @@ public class AccessEventDiscriminator extends ContextAwareBase implements
}
}
- public void stop() {
- started = false;
- }
-
public void setFieldName(FieldName fieldName) {
this.fieldName = fieldName;
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java
index 619fb3f7a..2d7a04e43 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java
@@ -14,8 +14,7 @@
package ch.qos.logback.classic.sift;
import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.sift.Discriminator;
-import ch.qos.logback.core.spi.ContextAwareBase;
+import ch.qos.logback.core.sift.AbstractDiscriminator;
/**
* This discriminator returns the value context to which this event is attached
@@ -27,12 +26,10 @@ import ch.qos.logback.core.spi.ContextAwareBase;
* @author Ceki Gülcü
*
*/
-public class ContextBasedDiscriminator extends ContextAwareBase implements
- Discriminator {
+public class ContextBasedDiscriminator extends AbstractDiscriminator {
private static final String KEY = "contextName";
private String defaultValue;
- private boolean started = false;
/**
* Return the name of the current context name as found in the logging event.
@@ -47,18 +44,6 @@ public class ContextBasedDiscriminator extends ContextAwareBase implements
}
}
- public boolean isStarted() {
- return started;
- }
-
- public void start() {
- started = true;
- }
-
- public void stop() {
- started = false;
- }
-
public String getKey() {
return KEY;
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/JNDIBasedContextDiscriminator.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/JNDIBasedContextDiscriminator.java
index 39375ca0a..b60e38934 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/JNDIBasedContextDiscriminator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/JNDIBasedContextDiscriminator.java
@@ -17,8 +17,7 @@ import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.selector.ContextSelector;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.util.ContextSelectorStaticBinder;
-import ch.qos.logback.core.sift.Discriminator;
-import ch.qos.logback.core.spi.ContextAwareBase;
+import ch.qos.logback.core.sift.AbstractDiscriminator;
/**
* This discriminator returns the value context as determined by JNDI. If the
@@ -30,12 +29,10 @@ import ch.qos.logback.core.spi.ContextAwareBase;
* @author Ceki Gülcü
*
*/
-public class JNDIBasedContextDiscriminator extends ContextAwareBase implements
- Discriminator {
+public class JNDIBasedContextDiscriminator extends AbstractDiscriminator {
private static final String KEY = "contextName";
private String defaultValue;
- private boolean started = false;
/**
* Return the name of the current context name as found in the logging event.
@@ -56,18 +53,6 @@ public class JNDIBasedContextDiscriminator extends ContextAwareBase implements
return lc.getName();
}
- public boolean isStarted() {
- return started;
- }
-
- public void start() {
- started = true;
- }
-
- public void stop() {
- started = false;
- }
-
public String getKey() {
return KEY;
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/MDCBasedDiscriminator.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/MDCBasedDiscriminator.java
index 7e15f5bfa..e6c9a50ba 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/MDCBasedDiscriminator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/MDCBasedDiscriminator.java
@@ -14,8 +14,7 @@
package ch.qos.logback.classic.sift;
import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.sift.Discriminator;
-import ch.qos.logback.core.spi.ContextAwareBase;
+import ch.qos.logback.core.sift.AbstractDiscriminator;
import ch.qos.logback.core.util.OptionHelper;
import java.util.Map;
@@ -28,12 +27,10 @@ import java.util.Map;
*
* @author Ceki Gülcü
*/
-public class MDCBasedDiscriminator extends ContextAwareBase implements
- Discriminator {
+public class MDCBasedDiscriminator extends AbstractDiscriminator {
private String key;
private String defaultValue;
- private boolean started = false;
/**
* Return the value associated with an MDC entry designated by the Key
@@ -54,10 +51,7 @@ public class MDCBasedDiscriminator extends ContextAwareBase implements
}
}
- public boolean isStarted() {
- return started;
- }
-
+ @Override
public void start() {
int errors = 0;
if (OptionHelper.isEmpty(key)) {
@@ -73,10 +67,6 @@ public class MDCBasedDiscriminator extends ContextAwareBase implements
}
}
- public void stop() {
- started = false;
- }
-
public String getKey() {
return key;
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/AbstractDiscriminator.java b/logback-core/src/main/java/ch/qos/logback/core/sift/AbstractDiscriminator.java
new file mode 100644
index 000000000..df1b8bb71
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/sift/AbstractDiscriminator.java
@@ -0,0 +1,26 @@
+package ch.qos.logback.core.sift;
+
+import ch.qos.logback.core.spi.ContextAwareBase;
+
+/**
+ * Base implementation of {@link Discriminator} that provides basic lifecycle management
+ *
+ * @author Tomasz Nurkiewicz
+ * @since 3/29/13, 3:28 PM
+ */
+public abstract class AbstractDiscriminator extends ContextAwareBase implements Discriminator {
+
+ protected boolean started;
+
+ public void start() {
+ started = true;
+ }
+
+ public void stop() {
+ started = false;
+ }
+
+ public boolean isStarted() {
+ return started;
+ }
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java b/logback-core/src/main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java
index 66c9c808c..fc0803906 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java
@@ -13,17 +13,14 @@
*/
package ch.qos.logback.core.sift;
-import ch.qos.logback.core.sift.Discriminator;
/**
* @author Ceki Gücü
*/
-public class DefaultDiscriminator implements Discriminator {
+public class DefaultDiscriminator extends AbstractDiscriminator {
static public final String DEFAULT = "default";
- boolean started = false;
-
public String getDiscriminatingValue(E e) {
return DEFAULT;
}
@@ -32,15 +29,4 @@ public class DefaultDiscriminator implements Discriminator {
return DEFAULT;
}
- public void start() {
- started = true;
- }
-
- public void stop() {
- started = false;
- }
-
- public boolean isStarted() {
- return started;
- }
}
--
GitLab
From c3a1f72c77990400a3b856e8d6699683d5cd7918 Mon Sep 17 00:00:00 2001
From: Tommy Becker
Date: Sat, 30 Mar 2013 21:36:39 -0400
Subject: [PATCH 007/260] Support attribute "optional" in include element
Support attribute "optional" in include element to prevent errors on
inclusion of non-existent files without requiring Janino and
FileExistsPropertyDefiner.
---
.../ch/qos/logback/core/joran/action/IncludeAction.java | 9 +++++++--
.../src/test/input/joran/inclusion/topOptional.xml | 9 +++++++++
.../qos/logback/core/joran/action/IncludeActionTest.java | 8 ++++++++
3 files changed, 24 insertions(+), 2 deletions(-)
create mode 100644 logback-core/src/test/input/joran/inclusion/topOptional.xml
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java
index 275d981d4..f615542c7 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IncludeAction.java
@@ -39,8 +39,10 @@ public class IncludeAction extends Action {
private static final String FILE_ATTR = "file";
private static final String URL_ATTR = "url";
private static final String RESOURCE_ATTR = "resource";
+ private static final String OPTIONAL_ATTR = "optional";
private String attributeInUse;
+ private boolean optional;
@Override
public void begin(InterpretationContext ec, String name, Attributes attributes)
@@ -49,6 +51,7 @@ public class IncludeAction extends Action {
SaxEventRecorder recorder = new SaxEventRecorder();
this.attributeInUse = null;
+ this.optional = OptionHelper.toBoolean(attributes.getValue(OPTIONAL_ATTR), false);
if (!checkAttributes(attributes)) {
return;
@@ -140,8 +143,10 @@ public class IncludeAction extends Action {
try {
return url.openStream();
} catch (IOException e) {
- String errMsg = "Failed to open [" + url.toString() + "]";
- addError(errMsg, e);
+ if (!optional) {
+ String errMsg = "Failed to open [" + url.toString() + "]";
+ addError(errMsg, e);
+ }
return null;
}
}
diff --git a/logback-core/src/test/input/joran/inclusion/topOptional.xml b/logback-core/src/test/input/joran/inclusion/topOptional.xml
new file mode 100644
index 000000000..3625575e2
--- /dev/null
+++ b/logback-core/src/test/input/joran/inclusion/topOptional.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java
index 5aee968be..ff3ad9c92 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/action/IncludeActionTest.java
@@ -60,6 +60,8 @@ public class IncludeActionTest {
static final String TOP_BY_FILE = INCLUSION_DIR_PREFIX + "topByFile.xml";
+ static final String TOP_OPTIONAL = INCLUSION_DIR_PREFIX + "topOptional.xml";
+
static final String INTERMEDIARY_FILE = INCLUSION_DIR_PREFIX
+ "intermediaryByFile.xml";
@@ -115,6 +117,12 @@ public class IncludeActionTest {
verifyConfig(new String[] { "IA", "IB" });
}
+ @Test
+ public void optionalFile() throws JoranException {
+ tc.doConfigure(TOP_OPTIONAL);
+ verifyConfig(new String[] { "IA", "IB" });
+ }
+
@Test
public void basicResource() throws JoranException {
System.setProperty(INCLUDE_KEY, INCLUDED_AS_RESOURCE);
--
GitLab
From 3ca5f37e6921a9f7f578b924a34a4afdd8fe169d Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 10:03:17 -0400
Subject: [PATCH 008/260] replaced references to "remote logger" with "remote
receiver"
In preparation for introducing the concept of a "receiver" component
(which can be either a component that listens passively for incoming
connections from remote peers or one that actively connects to a remote
peer), this commit fixes up the taxonomy in the ServerSocketAppenderBase
implementation. Now a ServerSocketAppender will have zero or more
connected remote receiver clients.
---
...erClient.java => RemoteReceiverClient.java} | 2 +-
....java => RemoteReceiverServerListener.java} | 14 +++++++-------
...er.java => RemoteReceiverServerRunner.java} | 14 +++++++-------
...nt.java => RemoteReceiverStreamClient.java} | 10 +++++-----
.../net/server/ServerSocketAppenderBase.java | 18 +++++++++---------
.../InstrumentedServerSocketAppenderBase.java | 16 ++++++++--------
...ava => RemoteReceiverStreamClientTest.java} | 8 ++++----
.../server/ServerSocketAppenderBaseTest.java | 8 ++++----
8 files changed, 45 insertions(+), 45 deletions(-)
rename logback-core/src/main/java/ch/qos/logback/core/net/server/{RemoteLoggerClient.java => RemoteReceiverClient.java} (95%)
rename logback-core/src/main/java/ch/qos/logback/core/net/server/{RemoteLoggerServerListener.java => RemoteReceiverServerListener.java} (74%)
rename logback-core/src/main/java/ch/qos/logback/core/net/server/{RemoteLoggerServerRunner.java => RemoteReceiverServerRunner.java} (75%)
rename logback-core/src/main/java/ch/qos/logback/core/net/server/{RemoteLoggerStreamClient.java => RemoteReceiverStreamClient.java} (91%)
rename logback-core/src/test/java/ch/qos/logback/core/net/server/{RemoteLoggerStreamClientTest.java => RemoteReceiverStreamClientTest.java} (91%)
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerClient.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverClient.java
similarity index 95%
rename from logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerClient.java
rename to logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverClient.java
index 1af2b908d..826602e74 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerClient.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverClient.java
@@ -26,7 +26,7 @@ import ch.qos.logback.core.spi.ContextAware;
*
* @author Carl Harris
*/
-interface RemoteLoggerClient extends Client, ContextAware {
+interface RemoteReceiverClient extends Client, ContextAware {
/**
* Sets the client's event queue.
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerListener.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerListener.java
similarity index 74%
rename from logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerListener.java
rename to logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerListener.java
index 70ca05a8e..e80936b1e 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerListener.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerListener.java
@@ -19,20 +19,20 @@ import java.net.ServerSocket;
import java.net.Socket;
/**
- * A {@link ServerListener} that accepts connections from remote logger
- * clients.
+ * A {@link ServerListener} that accepts connections from remote receiver
+ * component clients.
*
* @author Carl Harris
*/
-class RemoteLoggerServerListener
- extends ServerSocketListener {
+class RemoteReceiverServerListener
+ extends ServerSocketListener {
/**
* Constructs a new listener.
* @param serverSocket server socket from which new client connections
* will be accepted
*/
- public RemoteLoggerServerListener(ServerSocket serverSocket) {
+ public RemoteReceiverServerListener(ServerSocket serverSocket) {
super(serverSocket);
}
@@ -40,9 +40,9 @@ class RemoteLoggerServerListener
* {@inheritDoc}
*/
@Override
- protected RemoteLoggerClient createClient(String id, Socket socket)
+ protected RemoteReceiverClient createClient(String id, Socket socket)
throws IOException {
- return new RemoteLoggerStreamClient(id, socket);
+ return new RemoteReceiverStreamClient(id, socket);
}
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerRunner.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerRunner.java
similarity index 75%
rename from logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerRunner.java
rename to logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerRunner.java
index 47c01599a..8c0b9da9e 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerServerRunner.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverServerRunner.java
@@ -19,13 +19,13 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executor;
/**
- * A {@link ServerRunner} that sends logging events to remote logger
- * clients.
+ * A {@link ServerRunner} that listens for connections from remote receiver
+ * component clients and delivers logging events to all connected clients.
*
* @author Carl Harris
*/
-class RemoteLoggerServerRunner
- extends ConcurrentServerRunner {
+class RemoteReceiverServerRunner
+ extends ConcurrentServerRunner {
private final int clientQueueSize;
@@ -38,8 +38,8 @@ class RemoteLoggerServerRunner
* @param queueSize size of the event queue that will be maintained for
* each client
*/
- public RemoteLoggerServerRunner(
- ServerListener listener, Executor executor,
+ public RemoteReceiverServerRunner(
+ ServerListener listener, Executor executor,
int clientQueueSize) {
super(listener, executor);
this.clientQueueSize = clientQueueSize;
@@ -49,7 +49,7 @@ class RemoteLoggerServerRunner
* {@inheritDoc}
*/
@Override
- protected boolean configureClient(RemoteLoggerClient client) {
+ protected boolean configureClient(RemoteReceiverClient client) {
client.setContext(getContext());
client.setQueue(new ArrayBlockingQueue(clientQueueSize));
return true;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClient.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClient.java
similarity index 91%
rename from logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClient.java
rename to logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClient.java
index 57b83fbe9..c9c1c9a79 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClient.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClient.java
@@ -27,13 +27,13 @@ import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.util.CloseUtil;
/**
- * A {@link RemoteLoggerClient} that writes serialized logging events to an
+ * A {@link RemoteReceiverClient} that writes serialized logging events to an
* {@link OutputStream}.
*
* @author Carl Harris
*/
-class RemoteLoggerStreamClient
- extends ContextAwareBase implements RemoteLoggerClient {
+class RemoteReceiverStreamClient
+ extends ContextAwareBase implements RemoteReceiverClient {
private final String clientId;
private final Socket socket;
@@ -46,7 +46,7 @@ class RemoteLoggerStreamClient
* @param id identifier string for the client
* @param socket socket to which logging events will be written
*/
- public RemoteLoggerStreamClient(String id, Socket socket) {
+ public RemoteReceiverStreamClient(String id, Socket socket) {
this.clientId = "client " + id + ": ";
this.socket = socket;
this.outputStream = null;
@@ -61,7 +61,7 @@ class RemoteLoggerStreamClient
* @param id identifier string for the client
* @param outputStream output stream to which logging Events will be written
*/
- public RemoteLoggerStreamClient(String id, OutputStream outputStream) {
+ public RemoteReceiverStreamClient(String id, OutputStream outputStream) {
this.clientId = "client " + id + ": ";
this.socket = null;
this.outputStream = outputStream;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketAppenderBase.java
index 1b2f12526..dc5a854c0 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketAppenderBase.java
@@ -54,7 +54,7 @@ public abstract class ServerSocketAppenderBase extends AppenderBase {
private ThreadPoolFactoryBean threadPool;
private ExecutorService executor;
- private ServerRunner runner;
+ private ServerRunner runner;
@Override
public void start() {
@@ -62,7 +62,7 @@ public abstract class ServerSocketAppenderBase extends AppenderBase {
try {
ServerSocket socket = getServerSocketFactory().createServerSocket(
getPort(), getBacklog(), getInetAddress());
- ServerListener listener = createServerListener(socket);
+ ServerListener listener = createServerListener(socket);
executor = getThreadPool().createExecutor();
runner = createServerRunner(listener, executor);
runner.setContext(getContext());
@@ -74,15 +74,15 @@ public abstract class ServerSocketAppenderBase extends AppenderBase {
}
}
- protected ServerListener createServerListener(
+ protected ServerListener createServerListener(
ServerSocket socket) {
- return new RemoteLoggerServerListener(socket);
+ return new RemoteReceiverServerListener(socket);
}
- protected ServerRunner createServerRunner(
- ServerListener listener,
+ protected ServerRunner createServerRunner(
+ ServerListener listener,
Executor executor) {
- return new RemoteLoggerServerRunner(listener, executor,
+ return new RemoteReceiverServerRunner(listener, executor,
getClientQueueSize());
}
@@ -113,8 +113,8 @@ public abstract class ServerSocketAppenderBase extends AppenderBase {
if (event == null) return;
postProcessEvent(event);
final Serializable serEvent = getPST().transform(event);
- runner.accept(new ClientVisitor() {
- public void visit(RemoteLoggerClient client) {
+ runner.accept(new ClientVisitor() {
+ public void visit(RemoteReceiverClient client) {
client.offer(serEvent);
}
});
diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/InstrumentedServerSocketAppenderBase.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/InstrumentedServerSocketAppenderBase.java
index 19ce4124f..24a3cd694 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/net/server/InstrumentedServerSocketAppenderBase.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/InstrumentedServerSocketAppenderBase.java
@@ -33,18 +33,18 @@ public class InstrumentedServerSocketAppenderBase
extends ServerSocketAppenderBase {
private final ServerSocket serverSocket;
- private final ServerListener listener;
- private final ServerRunner runner;
+ private final ServerListener listener;
+ private final ServerRunner runner;
private ServerListener lastListener;
public InstrumentedServerSocketAppenderBase(ServerSocket serverSocket) {
- this(serverSocket, new RemoteLoggerServerListener(serverSocket), null);
+ this(serverSocket, new RemoteReceiverServerListener(serverSocket), null);
}
public InstrumentedServerSocketAppenderBase(ServerSocket serverSocket,
- ServerListener listener,
- ServerRunner runner) {
+ ServerListener listener,
+ ServerRunner runner) {
this.serverSocket = serverSocket;
this.listener = listener;
this.runner = runner;
@@ -87,14 +87,14 @@ public class InstrumentedServerSocketAppenderBase
}
@Override
- protected ServerRunner createServerRunner(
- ServerListener listener, Executor executor) {
+ protected ServerRunner createServerRunner(
+ ServerListener listener, Executor executor) {
lastListener = listener;
return runner != null ? runner : super.createServerRunner(listener, executor);
}
@Override
- protected ServerListener createServerListener(
+ protected ServerListener createServerListener(
ServerSocket socket) {
return listener;
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClientTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClientTest.java
similarity index 91%
rename from logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClientTest.java
rename to logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClientTest.java
index bfda20900..efafaf2f8 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteLoggerStreamClientTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/RemoteReceiverStreamClientTest.java
@@ -26,11 +26,11 @@ import org.junit.Test;
/**
- * Unit tests for {@link RemoteLoggerStreamClient}.
+ * Unit tests for {@link RemoteReceiverStreamClient}.
*
* @author Carl Harris
*/
-public class RemoteLoggerStreamClientTest {
+public class RemoteReceiverStreamClientTest {
private static final String TEST_EVENT = "test event";
@@ -41,8 +41,8 @@ public class RemoteLoggerStreamClientTest {
private ByteArrayOutputStream outputStream =
new ByteArrayOutputStream();
- private RemoteLoggerStreamClient client =
- new RemoteLoggerStreamClient("someId", outputStream);
+ private RemoteReceiverStreamClient client =
+ new RemoteReceiverStreamClient("someId", outputStream);
@Before
public void setUp() throws Exception {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseTest.java
index fd8fffa88..b36195f2c 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseTest.java
@@ -40,11 +40,11 @@ public class ServerSocketAppenderBaseTest {
private MockContext context = new MockContext();
- private MockServerRunner runner =
- new MockServerRunner();
+ private MockServerRunner runner =
+ new MockServerRunner();
- private MockServerListener listener =
- new MockServerListener();
+ private MockServerListener listener =
+ new MockServerListener();
private MockThreadPoolFactoryBean threadPool =
new MockThreadPoolFactoryBean();
--
GitLab
From 59e2b78dda2143aa69626d2dfce13d716e67f376 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 11:52:26 -0400
Subject: [PATCH 009/260] added ReceiverBase for receiver implementations
The existing SocketRemote and SocketServer classes will be refactored to
descend from this base class.
---
.../qos/logback/classic/net/ReceiverBase.java | 112 ++++++++++++++++++
1 file changed, 112 insertions(+)
create mode 100644 logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java
new file mode 100644
index 000000000..41cdcdb29
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java
@@ -0,0 +1,112 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+
+package ch.qos.logback.classic.net;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import ch.qos.logback.core.spi.ContextAwareBase;
+import ch.qos.logback.core.spi.LifeCycle;
+
+/**
+ * An abstract base for components that receive logging events from a remote
+ * peer and log according to local policy
+ *
+ * @author Carl Harris
+ */
+public abstract class ReceiverBase extends ContextAwareBase
+ implements LifeCycle, Runnable {
+
+ private ExecutorService executor;
+ private boolean started;
+
+ /**
+ * {@inheritDoc}
+ */
+ public final void start() {
+ if (isStarted()) return;
+ if (getContext() == null) {
+ throw new IllegalStateException("context not set");
+ }
+ if (shouldStart()) {
+ executor = createExecutorService();
+ executor.execute(this);
+ started = true;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final void stop() {
+ if (!isStarted()) return;
+ try {
+ onStop();
+ }
+ catch (RuntimeException ex) {
+ addError("on stop: " + ex, ex);
+ }
+ executor.shutdownNow();
+ started = false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final boolean isStarted() {
+ return started;
+ }
+
+ /**
+ * Determines whether this receiver should start.
+ *
+ * Subclasses will implement this method to do any subclass-specific
+ * validation. The subclass's {@link #run()} method will be invoked if
+ * and only if this method returns {@code true}.
+ * @return flag indicating whether this receiver should start
+ */
+ protected abstract boolean shouldStart();
+
+ /**
+ * Allows a subclass to participate in receiver shutdown.
+ */
+ protected abstract void onStop();
+
+ /**
+ * Creates an executor for concurrent execution of tasks associated with
+ * the receiver (including the receiver's {@link #run()} task itself.
+ *
+ * Subclasses may override to provide a custom executor.
+ *
+ * @return executor service
+ */
+ protected ExecutorService createExecutorService() {
+ return Executors.newCachedThreadPool();
+ }
+
+ /**
+ * Provides access to the receiver's executor.
+ *
+ * A subclass may use the executor returned by this method to run
+ * concurrent tasks as needed.
+ *
+ * @return executor
+ */
+ protected Executor getExecutor() {
+ return executor;
+ }
+
+}
--
GitLab
From e51b751bdc70fcd43b5e292044be0424122e398b Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 11:58:22 -0400
Subject: [PATCH 010/260] Transformed SocketRemoteAction and ServerAction into
ReceiverAction
ReceiverAction can instantiate a component that is a subtype of
ReceiverBase. SocketRemote and SocketServer will be refactored to
extend the ReceiverBase type.
---
.../classic/joran/JoranConfigurator.java | 9 +--
...tRemoteAction.java => ReceiverAction.java} | 23 +++---
.../classic/joran/action/ServerAction.java | 73 -------------------
3 files changed, 17 insertions(+), 88 deletions(-)
rename logback-classic/src/main/java/ch/qos/logback/classic/joran/action/{SocketRemoteAction.java => ReceiverAction.java} (70%)
delete mode 100644 logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ServerAction.java
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
index 4ce26cead..09b21df92 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
@@ -82,12 +82,9 @@ public class JoranConfigurator extends JoranConfiguratorBase {
rs.addRule(new Pattern("configuration/consolePlugin"),
new ConsolePluginAction());
- rs.addRule(new Pattern("configuration/server"),
- new ServerAction());
-
- rs.addRule(new Pattern("configuration/remote"),
- new SocketRemoteAction());
-
+ rs.addRule(new Pattern("configuration/receiver"),
+ new ReceiverAction());
+
}
@Override
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/SocketRemoteAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.java
similarity index 70%
rename from logback-classic/src/main/java/ch/qos/logback/classic/joran/action/SocketRemoteAction.java
rename to logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.java
index cc087be99..05b5a4025 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/SocketRemoteAction.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.java
@@ -15,42 +15,47 @@ package ch.qos.logback.classic.joran.action;
import org.xml.sax.Attributes;
-import ch.qos.logback.classic.net.SocketRemote;
+import ch.qos.logback.classic.net.ReceiverBase;
+import ch.qos.logback.classic.net.SocketReceiver;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.spi.ActionException;
import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.util.OptionHelper;
/**
- * A Joran {@link Action} for a {@link SocketRemote} configuration.
+ * A Joran {@link Action} for a {@link SocketReceiver} configuration.
*
* @author Carl Harris
*/
-public class SocketRemoteAction extends Action {
+public class ReceiverAction extends Action {
- private SocketRemote remote;
+ private SocketReceiver remote;
private boolean inError;
@Override
public void begin(InterpretationContext ic, String name,
Attributes attributes) throws ActionException {
+
String className = attributes.getValue(CLASS_ATTRIBUTE);
if (OptionHelper.isEmpty(className)) {
- className = SocketRemote.class.getCanonicalName();
+ addError("Missing class name for receiver. Near [" + name
+ + "] line " + getLineNumber(ic));
+ inError = true;
+ return;
}
try {
- addInfo("About to instantiate remote of type [" + className + "]");
+ addInfo("About to instantiate receiver of type [" + className + "]");
- remote = (SocketRemote) OptionHelper.instantiateByClassName(
- className, SocketRemote.class, context);
+ remote = (SocketReceiver) OptionHelper.instantiateByClassName(
+ className, ReceiverBase.class, context);
remote.setContext(context);
ic.pushObject(remote);
}
catch (Exception ex) {
inError = true;
- addError("Could not create a remote of type [" + className + "].", ex);
+ addError("Could not create a receiver of type [" + className + "].", ex);
throw new ActionException(ex);
}
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ServerAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ServerAction.java
deleted file mode 100644
index 5d0c4b11b..000000000
--- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ServerAction.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.classic.joran.action;
-
-import org.xml.sax.Attributes;
-
-import ch.qos.logback.classic.net.server.SocketServer;
-import ch.qos.logback.core.joran.action.Action;
-import ch.qos.logback.core.joran.spi.ActionException;
-import ch.qos.logback.core.joran.spi.InterpretationContext;
-import ch.qos.logback.core.util.OptionHelper;
-
-/**
- * A Joran {@link Action} for a server configuration.
- *
- * @author Carl Harris
- */
-public class ServerAction extends Action {
-
- private SocketServer server;
- private boolean inError;
-
- @Override
- public void begin(InterpretationContext ic, String name,
- Attributes attributes) throws ActionException {
- String className = attributes.getValue(CLASS_ATTRIBUTE);
- if (OptionHelper.isEmpty(className)) {
- className = SocketServer.class.getCanonicalName();
- }
- try {
- addInfo("About to instantiate server of type [" + className + "]");
-
- server = (SocketServer) OptionHelper.instantiateByClassName(className,
- SocketServer.class, context);
- server.setContext(context);
- ic.pushObject(server);
- }
- catch (Exception ex) {
- inError = true;
- addError("Could not create a server of type [" + className + "].", ex);
- throw new ActionException(ex);
- }
- }
-
- @Override
- public void end(InterpretationContext ic, String name)
- throws ActionException {
-
- if (inError) return;
-
- server.start();
-
- Object o = ic.peekObject();
- if (o != server) {
- addWarn("The object at the of the stack is not the server " +
- "pushed earlier.");
- } else {
- ic.popObject();
- }
- }
-
-}
--
GitLab
From e5acdb7dcdd4a886ab19783f1b3e4690a3647cc5 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 12:11:24 -0400
Subject: [PATCH 011/260] added SSLComponent interface to identify SSL
components for config
This will eliminate the need to add a nested component rule for each new
SSL component.
---
.../core/net/SSLSocketAppenderBase.java | 4 ++-
.../server/SSLServerSocketAppenderBase.java | 3 +-
.../logback/core/net/ssl/SSLComponent.java | 28 +++++++++++++++++++
3 files changed, 33 insertions(+), 2 deletions(-)
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLComponent.java
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SSLSocketAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SSLSocketAppenderBase.java
index 0ac377c38..7eb7cf3a8 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/SSLSocketAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/SSLSocketAppenderBase.java
@@ -17,6 +17,7 @@ import javax.net.SocketFactory;
import javax.net.ssl.SSLContext;
import ch.qos.logback.core.net.ssl.ConfigurableSSLSocketFactory;
+import ch.qos.logback.core.net.ssl.SSLComponent;
import ch.qos.logback.core.net.ssl.SSLConfiguration;
import ch.qos.logback.core.net.ssl.SSLParametersConfiguration;
@@ -26,7 +27,8 @@ import ch.qos.logback.core.net.ssl.SSLParametersConfiguration;
*
* @author Carl Harris
*/
-public abstract class SSLSocketAppenderBase extends SocketAppenderBase {
+public abstract class SSLSocketAppenderBase extends SocketAppenderBase
+ implements SSLComponent {
private SSLConfiguration ssl;
private SocketFactory socketFactory;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBase.java
index ba4865287..bb2f8051f 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/SSLServerSocketAppenderBase.java
@@ -17,6 +17,7 @@ import javax.net.ServerSocketFactory;
import javax.net.ssl.SSLContext;
import ch.qos.logback.core.net.ssl.ConfigurableSSLServerSocketFactory;
+import ch.qos.logback.core.net.ssl.SSLComponent;
import ch.qos.logback.core.net.ssl.SSLConfiguration;
import ch.qos.logback.core.net.ssl.SSLParametersConfiguration;
@@ -28,7 +29,7 @@ import ch.qos.logback.core.net.ssl.SSLParametersConfiguration;
* @author Carl Harris
*/
public abstract class SSLServerSocketAppenderBase
- extends ServerSocketAppenderBase {
+ extends ServerSocketAppenderBase implements SSLComponent {
private SSLConfiguration ssl;
private ServerSocketFactory socketFactory;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLComponent.java b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLComponent.java
new file mode 100644
index 000000000..f32dcffc3
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/ssl/SSLComponent.java
@@ -0,0 +1,28 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+
+package ch.qos.logback.core.net.ssl;
+
+/**
+ * A interface used to identify components that have an SSL configuration.
+ *
+ * @author Carl Harris
+ */
+public interface SSLComponent {
+
+ SSLConfiguration getSsl();
+
+ void setSsl(SSLConfiguration ssl);
+
+}
--
GitLab
From 4228a9e98eee1e3c3608ec31ac0096634bd1fd7d Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 12:12:34 -0400
Subject: [PATCH 012/260] modified nested component rules to use new
SSLComponent interface
---
.../logback/classic/util/DefaultNestedComponentRules.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/DefaultNestedComponentRules.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/DefaultNestedComponentRules.java
index e1f2e750d..70acd5fa7 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/util/DefaultNestedComponentRules.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/DefaultNestedComponentRules.java
@@ -16,14 +16,12 @@ package ch.qos.logback.classic.util;
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.boolex.JaninoEventEvaluator;
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
-import ch.qos.logback.classic.net.SSLSocketAppender;
-import ch.qos.logback.classic.net.SSLSocketRemote;
-import ch.qos.logback.classic.net.server.SSLServerSocketAppender;
import ch.qos.logback.classic.net.server.SocketServerNestedComponentRegistryRules;
import ch.qos.logback.core.AppenderBase;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
import ch.qos.logback.core.filter.EvaluatorFilter;
import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
+import ch.qos.logback.core.net.ssl.SSLComponent;
import ch.qos.logback.core.net.ssl.SSLConfiguration;
import ch.qos.logback.core.net.ssl.SSLNestedComponentRegistryRules;
@@ -47,9 +45,7 @@ public class DefaultNestedComponentRules {
registry
.add(EvaluatorFilter.class, "evaluator", JaninoEventEvaluator.class);
- registry.add(SSLSocketAppender.class, "ssl", SSLConfiguration.class);
- registry.add(SSLSocketRemote.class, "ssl", SSLConfiguration.class);
- registry.add(SSLServerSocketAppender.class, "ssl", SSLConfiguration.class);
+ registry.add(SSLComponent.class, "ssl", SSLConfiguration.class);
SSLNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry);
SocketServerNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry);
}
--
GitLab
From fab370acce32470874745c0ee1270227279b4bcd Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 12:13:15 -0400
Subject: [PATCH 013/260] modified JoranConfigurator to use new SSLComponent
interface
---
.../java/ch/qos/logback/access/joran/JoranConfigurator.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java b/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java
index 9ad01a159..f8fc1d48f 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java
@@ -19,8 +19,6 @@ import ch.qos.logback.access.PatternLayoutEncoder;
import ch.qos.logback.access.boolex.JaninoEventEvaluator;
import ch.qos.logback.access.joran.action.ConfigurationAction;
import ch.qos.logback.access.joran.action.EvaluatorAction;
-import ch.qos.logback.access.net.SSLSocketAppender;
-import ch.qos.logback.access.net.server.SSLServerSocketAppender;
import ch.qos.logback.access.sift.SiftAction;
import ch.qos.logback.core.AppenderBase;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
@@ -35,6 +33,7 @@ import ch.qos.logback.core.joran.conditional.ThenAction;
import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.joran.spi.RuleStore;
+import ch.qos.logback.core.net.ssl.SSLComponent;
import ch.qos.logback.core.net.ssl.SSLConfiguration;
import ch.qos.logback.core.net.ssl.SSLNestedComponentRegistryRules;
@@ -78,8 +77,7 @@ public class JoranConfigurator extends JoranConfiguratorBase {
registry.add(AppenderBase.class, "encoder", PatternLayoutEncoder.class);
registry.add(UnsynchronizedAppenderBase.class, "encoder", PatternLayoutEncoder.class);
- registry.add(SSLSocketAppender.class, "ssl", SSLConfiguration.class);
- registry.add(SSLServerSocketAppender.class, "ssl", SSLConfiguration.class);
+ registry.add(SSLComponent.class, "ssl", SSLConfiguration.class);
SSLNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry);
}
--
GitLab
From 66993de11e89846149d1553628858b6ee4869fd8 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 12:16:33 -0400
Subject: [PATCH 014/260] refactored SocketRemote to extend ReceiverBase
Also fixed up the taxonomy -- what was a SocketRemote is now a receiver
component that connects to a remote appender peer.
---
...cketRemote.java => SSLSocketReceiver.java} | 11 ++--
...{SocketRemote.java => SocketReceiver.java} | 53 ++++---------------
.../qos/logback/classic/net/PackageTest.java | 2 +-
...teTest.java => SSLSocketReceiverTest.java} | 16 +++---
...emoteTest.java => SocketReceiverTest.java} | 32 ++++++-----
5 files changed, 45 insertions(+), 69 deletions(-)
rename logback-classic/src/main/java/ch/qos/logback/classic/net/{SSLSocketRemote.java => SSLSocketReceiver.java} (88%)
rename logback-classic/src/main/java/ch/qos/logback/classic/net/{SocketRemote.java => SocketReceiver.java} (81%)
rename logback-classic/src/test/java/ch/qos/logback/classic/net/{SSLSocketRemoteTest.java => SSLSocketReceiverTest.java} (76%)
rename logback-classic/src/test/java/ch/qos/logback/classic/net/{SocketRemoteTest.java => SocketReceiverTest.java} (88%)
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketRemote.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketReceiver.java
similarity index 88%
rename from logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketRemote.java
rename to logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketReceiver.java
index e6cfc88b5..5d911f5b3 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketRemote.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SSLSocketReceiver.java
@@ -18,15 +18,17 @@ import javax.net.SocketFactory;
import javax.net.ssl.SSLContext;
import ch.qos.logback.core.net.ssl.ConfigurableSSLSocketFactory;
+import ch.qos.logback.core.net.ssl.SSLComponent;
import ch.qos.logback.core.net.ssl.SSLConfiguration;
import ch.qos.logback.core.net.ssl.SSLParametersConfiguration;
/**
- * A {@link SocketRemote} that supports SSL.
+ * A {@link SocketReceiver} that supports SSL.
*
* @author Carl Harris
*/
-public class SSLSocketRemote extends SocketRemote {
+public class SSLSocketReceiver extends SocketReceiver
+ implements SSLComponent {
private SSLConfiguration ssl;
private SocketFactory socketFactory;
@@ -45,17 +47,18 @@ public class SSLSocketRemote extends SocketRemote {
* {@inheritDoc}
*/
@Override
- public void start() {
+ protected boolean shouldStart() {
try {
SSLContext sslContext = getSsl().createContext(this);
SSLParametersConfiguration parameters = getSsl().getParameters();
parameters.setContext(getContext());
socketFactory = new ConfigurableSSLSocketFactory(parameters,
sslContext.getSocketFactory());
- super.start();
+ return super.shouldStart();
}
catch (Exception ex) {
addError(ex.getMessage(), ex);
+ return false;
}
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketRemote.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java
similarity index 81%
rename from logback-classic/src/main/java/ch/qos/logback/classic/net/SocketRemote.java
rename to logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java
index 525a79589..6ef539806 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketRemote.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java
@@ -27,17 +27,12 @@ import java.util.concurrent.RejectedExecutionException;
import javax.net.SocketFactory;
-import org.slf4j.ILoggerFactory;
-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.core.net.SocketAppenderBase;
import ch.qos.logback.core.net.SocketConnector;
import ch.qos.logback.core.net.SocketConnectorBase;
-import ch.qos.logback.core.spi.ContextAwareBase;
-import ch.qos.logback.core.spi.LifeCycle;
import ch.qos.logback.core.util.CloseUtil;
/**
@@ -46,8 +41,8 @@ import ch.qos.logback.core.util.CloseUtil;
*
* @author Carl Harris
*/
-public class SocketRemote extends ContextAwareBase
- implements LifeCycle, SocketConnector.ExceptionHandler, Runnable {
+public class SocketReceiver extends ReceiverBase
+ implements SocketConnector.ExceptionHandler {
private static final int DEFAULT_ACCEPT_CONNECTION_DELAY = 5000;
@@ -57,21 +52,13 @@ public class SocketRemote extends ContextAwareBase
private int reconnectionDelay;
private int acceptConnectionTimeout = DEFAULT_ACCEPT_CONNECTION_DELAY;
- private ExecutorService executor;
- private boolean started;
private String remoteId;
private volatile Socket socket;
/**
* {@inheritDoc}
*/
- public void start() {
- if (isStarted()) return;
-
- if (getContext() == null) {
- throw new IllegalStateException("context not set");
- }
-
+ protected boolean shouldStart() {
int errorCount = 0;
if (port == 0) {
errorCount++;
@@ -101,29 +88,18 @@ public class SocketRemote extends ContextAwareBase
if (errorCount == 0) {
remoteId = "remote " + host + ":" + port + ": ";
- executor = createExecutorService();
- executor.execute(this);
- started = true;
}
+
+ return errorCount == 0;
}
/**
* {@inheritDoc}
*/
- public void stop() {
- if (!isStarted()) return;
+ protected void onStop() {
if (socket != null) {
CloseUtil.closeQuietly(socket);
}
- executor.shutdownNow();
- started = false;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isStarted() {
- return started;
}
/**
@@ -131,13 +107,12 @@ public class SocketRemote extends ContextAwareBase
*/
public void run() {
try {
- LoggerContext lc = awaitConfiguration();
+ LoggerContext lc = (LoggerContext) getContext();
SocketConnector connector = createConnector(address, port, 0,
reconnectionDelay);
- while (!executor.isShutdown() &&
- !Thread.currentThread().isInterrupted()) {
+ while (!Thread.currentThread().isInterrupted()) {
try {
- executor.execute(connector);
+ getExecutor().execute(connector);
}
catch (RejectedExecutionException ex) {
// executor is shutting down...
@@ -154,16 +129,6 @@ public class SocketRemote extends ContextAwareBase
addInfo("shutting down");
}
- private LoggerContext awaitConfiguration() throws InterruptedException {
- ILoggerFactory factory = LoggerFactory.getILoggerFactory();
- while (!(factory instanceof LoggerContext)
- && !Thread.currentThread().isInterrupted()) {
- Thread.sleep(500);
- factory = LoggerFactory.getILoggerFactory();
- }
- return (LoggerContext) factory;
- }
-
private void dispatchEvents(LoggerContext lc) {
try {
socket.setSoTimeout(acceptConnectionTimeout);
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java
index e6b6d805f..72abdef4a 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/PackageTest.java
@@ -21,6 +21,6 @@ import org.junit.runners.Suite.SuiteClasses;
@SuiteClasses( { SyslogAppenderTest.class, DilutedSMTPAppenderTest.class,
SocketAppenderTest.class, JMSQueueAppenderTest.class, JMSTopicAppenderTest.class,
SMTPAppender_GreenTest.class, SMTPAppender_SubethaSMTPTest.class,
- SocketRemoteTest.class })
+ SocketReceiverTest.class, SSLSocketReceiverTest.class })
public class PackageTest {
}
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketRemoteTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketReceiverTest.java
similarity index 76%
rename from logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketRemoteTest.java
rename to logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketReceiverTest.java
index aae7c407b..48543a0da 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketRemoteTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SSLSocketReceiverTest.java
@@ -20,24 +20,24 @@ import java.net.InetAddress;
import org.junit.Before;
import org.junit.Test;
+import org.slf4j.LoggerFactory;
-import ch.qos.logback.core.net.mock.MockContext;
+import ch.qos.logback.classic.LoggerContext;
/**
- * Unit tests for {@link SSLSocketRemote}.
+ * Unit tests for {@link SSLSocketReceiver}.
*
* @author Carl Harris
*/
-public class SSLSocketRemoteTest {
+public class SSLSocketReceiverTest {
- private MockContext context = new MockContext();
-
- private SSLSocketRemote remote =
- new SSLSocketRemote();
+ private SSLSocketReceiver remote =
+ new SSLSocketReceiver();
@Before
public void setUp() throws Exception {
- remote.setContext(context);
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ remote.setContext(lc);
}
@Test
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketRemoteTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketReceiverTest.java
similarity index 88%
rename from logback-classic/src/test/java/ch/qos/logback/classic/net/SocketRemoteTest.java
rename to logback-classic/src/test/java/ch/qos/logback/classic/net/SocketReceiverTest.java
index fb54bba56..57a36aab5 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketRemoteTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketReceiverTest.java
@@ -45,15 +45,15 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.classic.spi.LoggingEventVO;
import ch.qos.logback.core.net.SocketConnector;
-import ch.qos.logback.core.net.mock.MockContext;
import ch.qos.logback.core.net.server.ServerSocketUtil;
+import ch.qos.logback.core.status.Status;
/**
- * Unit tests for {@link SocketRemote}.
+ * Unit tests for {@link SocketReceiver}.
*
* @author Carl Harris
*/
-public class SocketRemoteTest {
+public class SocketReceiverTest {
private static final int DELAY = 200;
private static final String TEST_HOST_NAME = "NOT.A.VALID.HOST.NAME";
@@ -62,15 +62,14 @@ public class SocketRemoteTest {
private ServerSocket serverSocket;
private Socket socket;
private ExecutorService executor = Executors.newCachedThreadPool();
- private MockContext context = new MockContext();
private MockSocketFactory socketFactory = new MockSocketFactory();
private MockSocketConnector connector;
private MockAppender appender;
private LoggerContext lc;
private Logger logger;
- private InstrumentedSocketRemote remote =
- new InstrumentedSocketRemote();
+ private InstrumentedSocketReceiver remote =
+ new InstrumentedSocketReceiver();
@Before
public void setUp() throws Exception {
@@ -78,9 +77,9 @@ public class SocketRemoteTest {
socket = new Socket(serverSocket.getInetAddress(),
serverSocket.getLocalPort());
connector = new MockSocketConnector(socket);
- remote.setContext(context);
lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ remote.setContext(lc);
appender = new MockAppender();
appender.start();
logger = lc.getLogger(getClass());
@@ -102,14 +101,20 @@ public class SocketRemoteTest {
@Test
public void testStartNoRemoteAddress() throws Exception {
remote.start();
- assertTrue(context.getLastStatus().getMessage().contains("host"));
+ assertFalse(remote.isStarted());
+ int count = lc.getStatusManager().getCount();
+ Status status = lc.getStatusManager().getCopyOfStatusList().get(count - 1);
+ assertTrue(status.getMessage().contains("host"));
}
@Test
public void testStartNoPort() throws Exception {
remote.setHost(TEST_HOST_NAME);
remote.start();
- assertTrue(context.getLastStatus().getMessage().contains("port"));
+ assertFalse(remote.isStarted());
+ int count = lc.getStatusManager().getCount();
+ Status status = lc.getStatusManager().getCopyOfStatusList().get(count - 1);
+ assertTrue(status.getMessage().contains("port"));
}
@Test
@@ -117,7 +122,10 @@ public class SocketRemoteTest {
remote.setPort(6000);
remote.setHost(TEST_HOST_NAME);
remote.start();
- assertTrue(context.getLastStatus().getMessage().contains("unknown host"));
+ assertFalse(remote.isStarted());
+ int count = lc.getStatusManager().getCount();
+ Status status = lc.getStatusManager().getCopyOfStatusList().get(count - 1);
+ assertTrue(status.getMessage().contains("unknown host"));
}
@Test
@@ -200,9 +208,9 @@ public class SocketRemoteTest {
}
/**
- * A {@link SocketRemote} with instrumentation for unit testing.
+ * A {@link SocketReceiver} with instrumentation for unit testing.
*/
- private class InstrumentedSocketRemote extends SocketRemote {
+ private class InstrumentedSocketReceiver extends SocketReceiver {
private boolean connectorCreated;
private boolean executorCreated;
--
GitLab
From 12474cb421beae6a3ceac9b4e8f0b3b92c972acb Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 14:04:21 -0400
Subject: [PATCH 015/260] removed ServerRunner.start method
The object that is composed with a ServerRunner already implements
LifeCycle. Having a start method complicates the use of the runner
without adding any real value.
---
.../net/server/ConcurrentServerRunner.java | 21 ++++++-------------
.../logback/core/net/server/ServerRunner.java | 20 +++++-------------
.../net/server/ServerSocketAppenderBase.java | 11 +---------
.../server/ConcurrentServerRunnerTest.java | 14 ++++++-------
.../core/net/server/MockServerRunner.java | 14 +++----------
.../net/server/MockThreadPoolFactoryBean.java | 1 +
.../server/ServerSocketAppenderBaseTest.java | 17 ++-------------
7 files changed, 25 insertions(+), 73 deletions(-)
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java
index 29e3dbef8..3047f468a 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java
@@ -55,7 +55,7 @@ public abstract class ConcurrentServerRunner
private final ServerListener listener;
private final Executor executor;
- private boolean started;
+ private boolean running;
/**
* Constructs a new server runner.
@@ -74,31 +74,20 @@ public abstract class ConcurrentServerRunner
/**
* {@inheritDoc}
*/
- public void start() throws IOException {
- if (isStarted()) return;
- executor.execute(this);
- started = true;
+ public boolean isRunning() {
+ return running;
}
/**
* {@inheritDoc}
*/
public void stop() throws IOException {
- if (!isStarted()) return;
listener.close();
accept(new ClientVisitor() {
public void visit(T client) {
client.close();
}
});
- started = false;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isStarted() {
- return started;
}
/**
@@ -136,6 +125,7 @@ public abstract class ConcurrentServerRunner
* {@inheritDoc}
*/
public void run() {
+ running = true;
try {
addInfo("listening on " + listener);
while (!Thread.currentThread().isInterrupted()) {
@@ -160,7 +150,8 @@ public abstract class ConcurrentServerRunner
catch (Exception ex) {
addError("listener: " + ex);
}
-
+
+ running = false;
addInfo("shutting down");
listener.close();
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerRunner.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerRunner.java
index b155cd9d5..0e2360211 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerRunner.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerRunner.java
@@ -26,18 +26,14 @@ import ch.qos.logback.core.spi.ContextAware;
*
* @author Carl Harris
*/
-public interface ServerRunner extends ContextAware {
+public interface ServerRunner extends ContextAware, Runnable {
/**
- * Starts execution of the runner.
- *
- * After scheduling execution of itself, the receiver must return
- * immediately. If the receiver is already running, this method must have
- * no effect.
- * @throws IOException
+ * Gets a flag indicating whether the server is currently running.
+ * @return flag state
*/
- void start() throws IOException;
-
+ boolean isRunning();
+
/**
* Stops execution of the runner.
*
@@ -48,12 +44,6 @@ public interface ServerRunner extends ContextAware {
*/
void stop() throws IOException;
- /**
- * Gets a flag indicating whether the receiver is running.
- * @return flag state
- */
- boolean isStarted();
-
/**
* Presents each connected client to the given visitor.
* @param visitor the subject visitor
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketAppenderBase.java
index dc5a854c0..d48e7978c 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/ServerSocketAppenderBase.java
@@ -66,7 +66,7 @@ public abstract class ServerSocketAppenderBase extends AppenderBase {
executor = getThreadPool().createExecutor();
runner = createServerRunner(listener, executor);
runner.setContext(getContext());
- runner.start();
+ executor.execute(runner);
super.start();
}
catch (Exception ex) {
@@ -99,15 +99,6 @@ public abstract class ServerSocketAppenderBase extends AppenderBase {
}
}
- /**
- * Gets a flag indicating whether the server is running.
- * @return flag state
- */
- @Override
- public final boolean isStarted() {
- return runner != null && runner.isStarted() && super.isStarted();
- }
-
@Override
protected void append(E event) {
if (event == null) return;
diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java
index 5044c1568..702fe8270 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java
@@ -51,9 +51,9 @@ public class ConcurrentServerRunnerTest {
@Test
public void testStartStop() throws Exception {
- assertFalse(runner.isStarted());
- runner.start();
- assertTrue(runner.isStarted());
+ assertFalse(runner.isRunning());
+ executor.execute(runner);
+ assertTrue(runner.isRunning());
int retries = 200;
synchronized (listener) {
while (retries-- > 0 && listener.getWaiter() == null) {
@@ -63,14 +63,14 @@ public class ConcurrentServerRunnerTest {
assertNotNull(listener.getWaiter());
runner.stop();
assertTrue(listener.isClosed());
- assertFalse(runner.isStarted());
+ assertFalse(runner.isRunning());
executor.shutdown();
assertTrue(executor.awaitTermination(2000, TimeUnit.MILLISECONDS));
}
@Test
public void testRunOneClient() throws Exception {
- runner.start();
+ executor.execute(runner);
MockClient client = new MockClient();
listener.addClient(client);
int retries = 200;
@@ -86,7 +86,7 @@ public class ConcurrentServerRunnerTest {
@Test
public void testRunManyClients() throws Exception {
- runner.start();
+ executor.execute(runner);
int count = 10;
while (count-- > 0) {
MockClient client = new MockClient();
@@ -104,7 +104,7 @@ public class ConcurrentServerRunnerTest {
@Test
public void testRunClientAndVisit() throws Exception {
- runner.start();
+ executor.execute(runner);
MockClient client = new MockClient();
listener.addClient(client);
int retries = 200;
diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerRunner.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerRunner.java
index 50a9b9a6a..71d6a9667 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerRunner.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockServerRunner.java
@@ -26,7 +26,6 @@ import ch.qos.logback.core.spi.ContextAwareBase;
public class MockServerRunner extends ContextAwareBase
implements ServerRunner {
- private IOException startException;
private IOException stopException;
private int startCount;
private boolean contextInjected;
@@ -37,10 +36,7 @@ public class MockServerRunner extends ContextAwareBase
super.setContext(context);
}
- public void start() throws IOException {
- if (startException != null) {
- throw startException;
- }
+ public void run() {
startCount++;
}
@@ -51,10 +47,10 @@ public class MockServerRunner extends ContextAwareBase
startCount--;
}
- public boolean isStarted() {
+ public boolean isRunning() {
return startCount > 0;
}
-
+
public void accept(ClientVisitor visitor) {
throw new UnsupportedOperationException();
}
@@ -67,10 +63,6 @@ public class MockServerRunner extends ContextAwareBase
return contextInjected;
}
- public void setStartException(IOException startException) {
- this.startException = startException;
- }
-
public void setStopException(IOException stopException) {
this.stopException = stopException;
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockThreadPoolFactoryBean.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockThreadPoolFactoryBean.java
index 15b4f025d..094b2f0ca 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/net/server/MockThreadPoolFactoryBean.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/MockThreadPoolFactoryBean.java
@@ -63,6 +63,7 @@ class MockThreadPoolFactoryBean extends ThreadPoolFactoryBean {
}
public void execute(Runnable command) {
+ command.run();
lastCommand = command;
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseTest.java
index b36195f2c..d6ee40336 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/ServerSocketAppenderBaseTest.java
@@ -69,24 +69,11 @@ public class ServerSocketAppenderBaseTest {
public void testStartStop() throws Exception {
appender.start();
assertTrue(runner.isContextInjected());
- assertTrue(runner.isStarted());
+ assertTrue(runner.isRunning());
assertSame(listener, appender.getLastListener());
appender.stop();
- assertFalse(runner.isStarted());
- }
-
- @Test
- public void testStartThrowsException() throws Exception {
- IOException ex = new IOException("test exception");
- runner.setStartException(ex);
- appender.start();
- assertFalse(appender.isStarted());
- Status status = context.getLastStatus();
- assertNotNull(status);
- assertTrue(status instanceof ErrorStatus);
- assertTrue(status.getMessage().contains(ex.getMessage()));
- assertSame(ex, status.getThrowable());
+ assertFalse(runner.isRunning());
}
@Test
--
GitLab
From 2c2520a882bd0cf3c9e679a3a3d7739389f97e84 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 14:11:34 -0400
Subject: [PATCH 016/260] a receiver now has-a Runnable, no longer is-a
Runnable
This will make it easier to refactor SocketServer so that it extends
ReceiverBase.
---
.../qos/logback/classic/net/ReceiverBase.java | 17 ++++++++++++-----
.../qos/logback/classic/net/SocketReceiver.java | 7 ++++++-
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java
index 41cdcdb29..5160fa752 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java
@@ -28,7 +28,7 @@ import ch.qos.logback.core.spi.LifeCycle;
* @author Carl Harris
*/
public abstract class ReceiverBase extends ContextAwareBase
- implements LifeCycle, Runnable {
+ implements LifeCycle {
private ExecutorService executor;
private boolean started;
@@ -43,9 +43,9 @@ public abstract class ReceiverBase extends ContextAwareBase
}
if (shouldStart()) {
executor = createExecutorService();
- executor.execute(this);
+ executor.execute(getRunnableTask());
started = true;
- }
+ }
}
/**
@@ -74,8 +74,9 @@ public abstract class ReceiverBase extends ContextAwareBase
* Determines whether this receiver should start.
*
* Subclasses will implement this method to do any subclass-specific
- * validation. The subclass's {@link #run()} method will be invoked if
- * and only if this method returns {@code true}.
+ * validation. The subclass's {@link #getRunnableTask()} method will be
+ * invoked (and the task returned will be submitted to the executor)
+ * if and only if this method returns {@code true}
* @return flag indicating whether this receiver should start
*/
protected abstract boolean shouldStart();
@@ -85,6 +86,12 @@ public abstract class ReceiverBase extends ContextAwareBase
*/
protected abstract void onStop();
+ /**
+ * Provides the runnable task this receiver will execute.
+ * @return runnable task
+ */
+ protected abstract Runnable getRunnableTask();
+
/**
* Creates an executor for concurrent execution of tasks associated with
* the receiver (including the receiver's {@link #run()} task itself.
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java
index 6ef539806..a6b80dc42 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketReceiver.java
@@ -42,7 +42,7 @@ import ch.qos.logback.core.util.CloseUtil;
* @author Carl Harris
*/
public class SocketReceiver extends ReceiverBase
- implements SocketConnector.ExceptionHandler {
+ implements Runnable, SocketConnector.ExceptionHandler {
private static final int DEFAULT_ACCEPT_CONNECTION_DELAY = 5000;
@@ -102,6 +102,11 @@ public class SocketReceiver extends ReceiverBase
}
}
+ @Override
+ protected Runnable getRunnableTask() {
+ return this;
+ }
+
/**
* {@inheritDoc}
*/
--
GitLab
From 32bcbbe5ef6ee192d427cc99dbf10d2ae06b9ac5 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 14:14:49 -0400
Subject: [PATCH 017/260] refactored SocketServer so that it extends
ReceiverBase
---
...rver.java => SSLServerSocketReceiver.java} | 6 ++-
...tServer.java => ServerSocketReceiver.java} | 50 ++++++++++---------
...ketServerNestedComponentRegistryRules.java | 6 +--
... => InstrumentedServerSocketReceiver.java} | 10 ++--
.../net/server/MockThreadPoolFactoryBean.java | 1 +
....java => SSLServerSocketReceiverTest.java} | 12 ++---
...> ServerSocketReceiverFunctionalTest.java} | 18 +++----
...est.java => ServerSocketReceiverTest.java} | 47 +++++++----------
8 files changed, 72 insertions(+), 78 deletions(-)
rename logback-classic/src/main/java/ch/qos/logback/classic/net/server/{SSLSocketServer.java => SSLServerSocketReceiver.java} (90%)
rename logback-classic/src/main/java/ch/qos/logback/classic/net/server/{SocketServer.java => ServerSocketReceiver.java} (84%)
rename logback-classic/src/test/java/ch/qos/logback/classic/net/server/{InstrumentedSocketServer.java => InstrumentedServerSocketReceiver.java} (87%)
rename logback-classic/src/test/java/ch/qos/logback/classic/net/server/{SSLSocketServerTest.java => SSLServerSocketReceiverTest.java} (81%)
rename logback-classic/src/test/java/ch/qos/logback/classic/net/server/{SocketServerFunctionalTest.java => ServerSocketReceiverFunctionalTest.java} (88%)
rename logback-classic/src/test/java/ch/qos/logback/classic/net/server/{SocketServerTest.java => ServerSocketReceiverTest.java} (70%)
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLSocketServer.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiver.java
similarity index 90%
rename from logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLSocketServer.java
rename to logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiver.java
index 05af69688..6abc73454 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLSocketServer.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiver.java
@@ -17,15 +17,17 @@ import javax.net.ServerSocketFactory;
import javax.net.ssl.SSLContext;
import ch.qos.logback.core.net.ssl.ConfigurableSSLServerSocketFactory;
+import ch.qos.logback.core.net.ssl.SSLComponent;
import ch.qos.logback.core.net.ssl.SSLConfiguration;
import ch.qos.logback.core.net.ssl.SSLParametersConfiguration;
/**
- * A {@link SocketServer} that supports SSL.
+ * A {@link ServerSocketReceiver} that supports SSL.
*
* @author Carl Harris
*/
-public class SSLSocketServer extends SocketServer {
+public class SSLServerSocketReceiver extends ServerSocketReceiver
+ implements SSLComponent {
private SSLConfiguration ssl;
private ServerSocketFactory socketFactory;
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServer.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/ServerSocketReceiver.java
similarity index 84%
rename from logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServer.java
rename to logback-classic/src/main/java/ch/qos/logback/classic/net/server/ServerSocketReceiver.java
index ee958793f..31f074247 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServer.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/ServerSocketReceiver.java
@@ -22,19 +22,19 @@ import java.util.concurrent.ExecutorService;
import javax.net.ServerSocketFactory;
+import ch.qos.logback.classic.net.ReceiverBase;
import ch.qos.logback.core.net.SocketAppenderBase;
import ch.qos.logback.core.net.server.ServerListener;
import ch.qos.logback.core.net.server.ServerRunner;
import ch.qos.logback.core.net.server.ThreadPoolFactoryBean;
-import ch.qos.logback.core.spi.ContextAwareBase;
-import ch.qos.logback.core.spi.LifeCycle;
+import ch.qos.logback.core.util.CloseUtil;
/**
* A logging socket server that is configurable using Joran.
*
* @author Carl Harris
*/
-public class SocketServer extends ContextAwareBase implements LifeCycle {
+public class ServerSocketReceiver extends ReceiverBase {
/**
* Default {@link ServerSocket} backlog
@@ -47,25 +47,28 @@ public class SocketServer extends ContextAwareBase implements LifeCycle {
private String address;
private ThreadPoolFactoryBean threadPool;
+ private ServerSocket serverSocket;
private ServerRunner runner;
- private ExecutorService executor;
/**
* Starts the server.
*/
- public final void start() {
- if (isStarted()) return;
+ protected boolean shouldStart() {
try {
- ServerSocket socket = getServerSocketFactory().createServerSocket(
+ ServerSocket serverSocket = getServerSocketFactory().createServerSocket(
getPort(), getBacklog(), getInetAddress());
- ServerListener listener = createServerListener(socket);
- executor = getThreadPool().createExecutor();
- runner = createServerRunner(listener, executor);
+
+ ServerListener listener =
+ createServerListener(serverSocket);
+
+ runner = createServerRunner(listener, getExecutor());
runner.setContext(getContext());
- runner.start();
+ return true;
}
catch (Exception ex) {
addError("server startup error: " + ex, ex);
+ CloseUtil.closeQuietly(serverSocket);
+ return false;
}
}
@@ -80,28 +83,29 @@ public class SocketServer extends ContextAwareBase implements LifeCycle {
return new RemoteAppenderServerRunner(listener, executor);
}
+ @Override
+ protected ExecutorService createExecutorService() {
+ return getThreadPool().createExecutor();
+ }
+
+ @Override
+ protected Runnable getRunnableTask() {
+ return runner;
+ }
+
/**
- * Stops the server.
+ * {@inheritDoc}
*/
- public final void stop() {
- if (!isStarted()) return;
+ protected void onStop() {
try {
+ if (runner == null) return;
runner.stop();
- executor.shutdownNow();
}
catch (IOException ex) {
addError("server shutdown error: " + ex, ex);
}
}
- /**
- * Gets a flag indicating whether the server is running.
- * @return flag state
- */
- public final boolean isStarted() {
- return runner != null && runner.isStarted();
- }
-
/**
* Gets the server socket factory.
*
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServerNestedComponentRegistryRules.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServerNestedComponentRegistryRules.java
index 148789b57..51905ec0e 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServerNestedComponentRegistryRules.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/server/SocketServerNestedComponentRegistryRules.java
@@ -18,7 +18,7 @@ import ch.qos.logback.core.net.server.ThreadPoolFactoryBean;
import ch.qos.logback.core.net.ssl.SSLConfiguration;
/**
- * Nested component registry rules for {@link SocketServer}.
+ * Nested component registry rules for {@link ServerSocketReceiver}.
*
* @author Carl Harris
*/
@@ -27,9 +27,9 @@ public class SocketServerNestedComponentRegistryRules {
public static void addDefaultNestedComponentRegistryRules(
DefaultNestedComponentRegistry registry) {
- registry.add(SocketServer.class, "threadPool",
+ registry.add(ServerSocketReceiver.class, "threadPool",
ThreadPoolFactoryBean.class);
- registry.add(SSLSocketServer.class, "ssl",
+ registry.add(SSLServerSocketReceiver.class, "ssl",
SSLConfiguration.class);
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedSocketServer.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedServerSocketReceiver.java
similarity index 87%
rename from logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedSocketServer.java
rename to logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedServerSocketReceiver.java
index 895d39013..732c776b5 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedSocketServer.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/InstrumentedServerSocketReceiver.java
@@ -22,17 +22,17 @@ import javax.net.ServerSocketFactory;
import ch.qos.logback.classic.net.server.RemoteAppenderClient;
import ch.qos.logback.classic.net.server.RemoteAppenderServerListener;
-import ch.qos.logback.classic.net.server.SocketServer;
+import ch.qos.logback.classic.net.server.ServerSocketReceiver;
import ch.qos.logback.core.net.server.ServerListener;
import ch.qos.logback.core.net.server.ServerRunner;
/**
- * A {@link SocketServer} with instrumentation for unit testing.
+ * A {@link ServerSocketReceiver} with instrumentation for unit testing.
*
* @author Carl Harris
*/
-public class InstrumentedSocketServer extends SocketServer {
+public class InstrumentedServerSocketReceiver extends ServerSocketReceiver {
private final ServerSocket serverSocket;
private final ServerListener listener;
@@ -40,11 +40,11 @@ public class InstrumentedSocketServer extends SocketServer {
private ServerListener lastListener;
- public InstrumentedSocketServer(ServerSocket serverSocket) {
+ public InstrumentedServerSocketReceiver(ServerSocket serverSocket) {
this(serverSocket, new RemoteAppenderServerListener(serverSocket), null);
}
- public InstrumentedSocketServer(ServerSocket serverSocket,
+ public InstrumentedServerSocketReceiver(ServerSocket serverSocket,
ServerListener listener,
ServerRunner runner) {
this.serverSocket = serverSocket;
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockThreadPoolFactoryBean.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockThreadPoolFactoryBean.java
index 007331220..5a87ba8f2 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockThreadPoolFactoryBean.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/MockThreadPoolFactoryBean.java
@@ -65,6 +65,7 @@ class MockThreadPoolFactoryBean extends ThreadPoolFactoryBean {
}
public void execute(Runnable command) {
+ command.run();
lastCommand = command;
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLSocketServerTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiverTest.java
similarity index 81%
rename from logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLSocketServerTest.java
rename to logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiverTest.java
index 1fba4a0fa..3fe1ea860 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLSocketServerTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SSLServerSocketReceiverTest.java
@@ -24,11 +24,11 @@ import org.junit.Test;
import ch.qos.logback.core.net.server.MockContext;
/**
- * Unit tests for {@link SSLSocketServer}.
+ * Unit tests for {@link SSLServerSocketReceiver}.
*
* @author Carl Harris
*/
-public class SSLSocketServerTest {
+public class SSLServerSocketReceiverTest {
private MockContext context = new MockContext();
@@ -37,18 +37,18 @@ public class SSLSocketServerTest {
private MockSSLParametersConfiguration parameters =
new MockSSLParametersConfiguration();
- private SSLSocketServer socketServer = new SSLSocketServer();
+ private SSLServerSocketReceiver receiver = new SSLServerSocketReceiver();
@Before
public void setUp() throws Exception {
- socketServer.setContext(context);
- socketServer.setSsl(ssl);
+ receiver.setContext(context);
+ receiver.setSsl(ssl);
ssl.setParameters(parameters);
}
@Test
public void testGetServerSocketFactory() throws Exception {
- ServerSocketFactory socketFactory = socketServer.getServerSocketFactory();
+ ServerSocketFactory socketFactory = receiver.getServerSocketFactory();
assertNotNull(socketFactory);
assertTrue(ssl.isContextCreated());
assertTrue(parameters.isContextInjected());
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerFunctionalTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverFunctionalTest.java
similarity index 88%
rename from logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerFunctionalTest.java
rename to logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverFunctionalTest.java
index 182eeb48d..ee01823b6 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerFunctionalTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverFunctionalTest.java
@@ -41,13 +41,13 @@ import ch.qos.logback.core.net.server.ServerSocketUtil;
import ch.qos.logback.core.net.server.ThreadPoolFactoryBean;
/**
- * A functional test for {@link SocketServer}.
+ * A functional test for {@link ServerSocketReceiver}.
*
* In this test we create a SocketServer, connect to it over the local
* network interface, and validate that it receives messages and delivers
* them to its appender.
*/
-public class SocketServerFunctionalTest {
+public class ServerSocketReceiverFunctionalTest {
private static final int EVENT_COUNT = 10;
private static final int SHUTDOWN_DELAY = 10000;
@@ -55,8 +55,8 @@ public class SocketServerFunctionalTest {
private MockAppender appender;
private Logger logger;
private ServerSocket serverSocket;
- private ExecutorService executor = Executors.newFixedThreadPool(2);
- private InstrumentedSocketServer socketServer;
+ private ExecutorService executor = Executors.newCachedThreadPool();
+ private InstrumentedServerSocketReceiver receiver;
@Before
public void setUp() throws Exception {
@@ -70,21 +70,22 @@ public class SocketServerFunctionalTest {
serverSocket = ServerSocketUtil.createServerSocket();
- socketServer = new InstrumentedSocketServer(serverSocket);
+ receiver = new InstrumentedServerSocketReceiver(serverSocket);
- socketServer.setThreadPool(new ThreadPoolFactoryBean() {
+ receiver.setThreadPool(new ThreadPoolFactoryBean() {
@Override
public ExecutorService createExecutor() {
return executor;
}
});
- socketServer.setContext(lc);
+ receiver.setContext(lc);
+ receiver.start();
}
@After
public void tearDown() throws Exception {
- socketServer.stop();
+ receiver.stop();
executor.awaitTermination(SHUTDOWN_DELAY, TimeUnit.MILLISECONDS);
assertTrue(executor.isTerminated());
}
@@ -93,7 +94,6 @@ public class SocketServerFunctionalTest {
public void testLogEventFromClient() throws Exception {
ILoggingEvent event = new LoggingEvent(logger.getName(), logger,
Level.DEBUG, "test message", null, new Object[0]);
- socketServer.start();
Socket socket = new Socket(InetAddress.getLocalHost(),
serverSocket.getLocalPort());
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverTest.java
similarity index 70%
rename from logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerTest.java
rename to logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverTest.java
index d870cb727..b2c66d557 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/server/SocketServerTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/server/ServerSocketReceiverTest.java
@@ -34,11 +34,11 @@ import ch.qos.logback.core.status.ErrorStatus;
import ch.qos.logback.core.status.Status;
/**
- * Unit tests for {@link SocketServer}.
+ * Unit tests for {@link ServerSocketReceiver}.
*
* @author Carl Harris
*/
-public class SocketServerTest {
+public class ServerSocketReceiverTest {
private MockContext context = new MockContext();
@@ -52,14 +52,14 @@ public class SocketServerTest {
new MockThreadPoolFactoryBean();
private ServerSocket serverSocket;
- private InstrumentedSocketServer socketServer;
+ private InstrumentedServerSocketReceiver receiver;
@Before
public void setUp() throws Exception {
serverSocket = ServerSocketUtil.createServerSocket();
- socketServer = new InstrumentedSocketServer(serverSocket, listener, runner);
- socketServer.setThreadPool(threadPool);
- socketServer.setContext(context);
+ receiver = new InstrumentedServerSocketReceiver(serverSocket, listener, runner);
+ receiver.setThreadPool(threadPool);
+ receiver.setContext(context);
}
@After
@@ -69,42 +69,29 @@ public class SocketServerTest {
@Test
public void testStartStop() throws Exception {
- socketServer.start();
+ receiver.start();
assertTrue(runner.isContextInjected());
- assertTrue(runner.isStarted());
- assertSame(listener, socketServer.getLastListener());
+ assertTrue(runner.isRunning());
+ assertSame(listener, receiver.getLastListener());
- socketServer.stop();
- assertFalse(runner.isStarted());
- }
-
- @Test
- public void testStartThrowsException() throws Exception {
- IOException ex = new IOException("test exception");
- runner.setStartException(ex);
- socketServer.start();
- assertFalse(socketServer.isStarted());
- Status status = context.getLastStatus();
- assertNotNull(status);
- assertTrue(status instanceof ErrorStatus);
- assertTrue(status.getMessage().contains(ex.getMessage()));
- assertSame(ex, status.getThrowable());
+ receiver.stop();
+ assertFalse(runner.isRunning());
}
@Test
public void testStartWhenAlreadyStarted() throws Exception {
- socketServer.start();
- socketServer.start();
+ receiver.start();
+ receiver.start();
assertEquals(1, runner.getStartCount());
}
@Test
public void testStopThrowsException() throws Exception {
- socketServer.start();
- assertTrue(socketServer.isStarted());
+ receiver.start();
+ assertTrue(receiver.isStarted());
IOException ex = new IOException("test exception");
runner.setStopException(ex);
- socketServer.stop();
+ receiver.stop();
Status status = context.getLastStatus();
assertNotNull(status);
@@ -115,7 +102,7 @@ public class SocketServerTest {
@Test
public void testStopWhenNotStarted() throws Exception {
- socketServer.stop();
+ receiver.stop();
assertEquals(0, runner.getStartCount());
}
--
GitLab
From 391c1207fca131ea6ca629d8e201a465910edef4 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 14:26:55 -0400
Subject: [PATCH 018/260] ReceiverBase.start now creates executor before
calling shouldStart
The subclass may need a reference to executor to pass to objects that
will need it later when the receiver is running.
---
.../main/java/ch/qos/logback/classic/net/ReceiverBase.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java
index 5160fa752..d5c2d0015 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/ReceiverBase.java
@@ -41,11 +41,15 @@ public abstract class ReceiverBase extends ContextAwareBase
if (getContext() == null) {
throw new IllegalStateException("context not set");
}
+
+ executor = createExecutorService();
if (shouldStart()) {
- executor = createExecutorService();
executor.execute(getRunnableTask());
started = true;
}
+ else {
+ executor.shutdownNow();
+ }
}
/**
--
GitLab
From babb52e3be69f5e7c259fd325393af95c351fffa Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 18:05:49 -0400
Subject: [PATCH 019/260] reworked examples replacing to "server" and "remote"
with "receiver"
---
...emoteServer.java => ServerSocketAppender1.java} | 6 +++---
...ocketServer.java => ServerSocketReceiver1.java} | 7 ++++---
...ocketRemoteClient.java => SocketReceiver1.java} | 4 ++--
.../socket/{remoteClient.xml => client2.xml} | 14 +++++++-------
.../java/chapters/appenders/socket/server3.xml | 6 +++---
.../socket/{remoteServer.xml => server4.xml} | 0
.../socket/ssl/{remoteClient.xml => client2.xml} | 14 +++++++-------
.../java/chapters/appenders/socket/ssl/server2.xml | 6 +++---
.../socket/ssl/{remoteServer.xml => server3.xml} | 0
9 files changed, 29 insertions(+), 28 deletions(-)
rename logback-examples/src/main/java/chapters/appenders/socket/{SocketRemoteServer.java => ServerSocketAppender1.java} (92%)
rename logback-examples/src/main/java/chapters/appenders/socket/{SocketServer.java => ServerSocketReceiver1.java} (88%)
rename logback-examples/src/main/java/chapters/appenders/socket/{SocketRemoteClient.java => SocketReceiver1.java} (94%)
rename logback-examples/src/main/java/chapters/appenders/socket/{remoteClient.xml => client2.xml} (81%)
rename logback-examples/src/main/java/chapters/appenders/socket/{remoteServer.xml => server4.xml} (100%)
rename logback-examples/src/main/java/chapters/appenders/socket/ssl/{remoteClient.xml => client2.xml} (84%)
rename logback-examples/src/main/java/chapters/appenders/socket/ssl/{remoteServer.xml => server3.xml} (100%)
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteServer.java b/logback-examples/src/main/java/chapters/appenders/socket/ServerSocketAppender1.java
similarity index 92%
rename from logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteServer.java
rename to logback-examples/src/main/java/chapters/appenders/socket/ServerSocketAppender1.java
index ca39388b9..8ecff7fec 100644
--- a/logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteServer.java
+++ b/logback-examples/src/main/java/chapters/appenders/socket/ServerSocketAppender1.java
@@ -32,11 +32,11 @@ import ch.qos.logback.classic.joran.JoranConfigurator;
* {@link ServerSocketAppender} and then allows the user to enter messages
* which will be relayed to remote clients via this appender.
*/
-public class SocketRemoteServer {
+public class ServerSocketAppender1 {
static void usage(String msg) {
System.err.println(msg);
- System.err.println("Usage: java " + SocketRemoteServer.class.getName() +
+ System.err.println("Usage: java " + ServerSocketAppender1.class.getName() +
" configFile\n" +
" configFile a logback configuration file" +
" in XML format.");
@@ -58,7 +58,7 @@ public class SocketRemoteServer {
configurator.doConfigure(configFile);
}
- Logger logger = LoggerFactory.getLogger(SocketRemoteServer.class);
+ Logger logger = LoggerFactory.getLogger(ServerSocketAppender1.class);
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/SocketServer.java b/logback-examples/src/main/java/chapters/appenders/socket/ServerSocketReceiver1.java
similarity index 88%
rename from logback-examples/src/main/java/chapters/appenders/socket/SocketServer.java
rename to logback-examples/src/main/java/chapters/appenders/socket/ServerSocketReceiver1.java
index a4c8338cf..11967f925 100644
--- a/logback-examples/src/main/java/chapters/appenders/socket/SocketServer.java
+++ b/logback-examples/src/main/java/chapters/appenders/socket/ServerSocketReceiver1.java
@@ -20,14 +20,15 @@ import ch.qos.logback.classic.joran.JoranConfigurator;
/**
- * This application uses an SSLSocketServer that log messages to a
+ * This application uses a SocketAppender that log messages to a
* server on a host and port specified by the user. It waits for the
* user to type a message which will be sent to the server.
* */
-public class SocketServer {
+public class ServerSocketReceiver1 {
+
static void usage(String msg) {
System.err.println(msg);
- System.err.println("Usage: java " + SocketServer.class.getName() +
+ System.err.println("Usage: java " + ServerSocketReceiver1.class.getName() +
" configFile\n" +
" configFile a logback configuration file" +
" in XML format.");
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteClient.java b/logback-examples/src/main/java/chapters/appenders/socket/SocketReceiver1.java
similarity index 94%
rename from logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteClient.java
rename to logback-examples/src/main/java/chapters/appenders/socket/SocketReceiver1.java
index 900574857..c7e2db7e7 100644
--- a/logback-examples/src/main/java/chapters/appenders/socket/SocketRemoteClient.java
+++ b/logback-examples/src/main/java/chapters/appenders/socket/SocketReceiver1.java
@@ -28,11 +28,11 @@ import ch.qos.logback.classic.joran.JoranConfigurator;
* {@link SocketRemote} and then logs events received from the remote
* appender to the console.
*/
-public class SocketRemoteClient {
+public class SocketReceiver1 {
static void usage(String msg) {
System.err.println(msg);
- System.err.println("Usage: java " + SocketRemoteClient.class.getName() +
+ System.err.println("Usage: java " + SocketReceiver1.class.getName() +
" configFile\n" +
" configFile a logback configuration file" +
" in XML format.");
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/remoteClient.xml b/logback-examples/src/main/java/chapters/appenders/socket/client2.xml
similarity index 81%
rename from logback-examples/src/main/java/chapters/appenders/socket/remoteClient.xml
rename to logback-examples/src/main/java/chapters/appenders/socket/client2.xml
index f48ed0d0c..acfc2759a 100644
--- a/logback-examples/src/main/java/chapters/appenders/socket/remoteClient.xml
+++ b/logback-examples/src/main/java/chapters/appenders/socket/client2.xml
@@ -1,7 +1,7 @@
-
+
@@ -11,17 +11,17 @@
%date %-5level [%thread] %logger - %message%n
+
+
+
+
-
+ ${host}${port}10000
-
+
-
-
-
-
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/server3.xml b/logback-examples/src/main/java/chapters/appenders/socket/server3.xml
index f9e1e2294..b66cb886a 100644
--- a/logback-examples/src/main/java/chapters/appenders/socket/server3.xml
+++ b/logback-examples/src/main/java/chapters/appenders/socket/server3.xml
@@ -1,7 +1,7 @@
-
+
@@ -16,9 +16,9 @@
-
+ ${port}
-
+
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/remoteServer.xml b/logback-examples/src/main/java/chapters/appenders/socket/server4.xml
similarity index 100%
rename from logback-examples/src/main/java/chapters/appenders/socket/remoteServer.xml
rename to logback-examples/src/main/java/chapters/appenders/socket/server4.xml
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteClient.xml b/logback-examples/src/main/java/chapters/appenders/socket/ssl/client2.xml
similarity index 84%
rename from logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteClient.xml
rename to logback-examples/src/main/java/chapters/appenders/socket/ssl/client2.xml
index 707ff433a..50edf2a79 100644
--- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteClient.xml
+++ b/logback-examples/src/main/java/chapters/appenders/socket/ssl/client2.xml
@@ -1,7 +1,7 @@
-
+
@@ -12,7 +12,11 @@
-
+
+
+
+
+ ${host}${port}10000
@@ -22,12 +26,8 @@
${password}
-
+
-
-
-
-
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml b/logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml
index 395b44d09..62e5edc69 100644
--- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml
+++ b/logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml
@@ -1,7 +1,7 @@
-
+
@@ -16,7 +16,7 @@
-
+ ${port}
@@ -24,7 +24,7 @@
${password}
-
+
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteServer.xml b/logback-examples/src/main/java/chapters/appenders/socket/ssl/server3.xml
similarity index 100%
rename from logback-examples/src/main/java/chapters/appenders/socket/ssl/remoteServer.xml
rename to logback-examples/src/main/java/chapters/appenders/socket/ssl/server3.xml
--
GitLab
From dc054c4a49a6a61ebabd0e4b2e9c7acba3dd1bd3 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 18:06:40 -0400
Subject: [PATCH 020/260] ReceiverAction now casts to ReceiverBase, not
SocketReceiver
---
.../logback/classic/joran/action/ReceiverAction.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.java
index 05b5a4025..6a9d65d9c 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ReceiverAction.java
@@ -29,7 +29,7 @@ import ch.qos.logback.core.util.OptionHelper;
*/
public class ReceiverAction extends Action {
- private SocketReceiver remote;
+ private ReceiverBase receiver;
private boolean inError;
@Override
@@ -47,11 +47,11 @@ public class ReceiverAction extends Action {
try {
addInfo("About to instantiate receiver of type [" + className + "]");
- remote = (SocketReceiver) OptionHelper.instantiateByClassName(
+ receiver = (ReceiverBase) OptionHelper.instantiateByClassName(
className, ReceiverBase.class, context);
- remote.setContext(context);
+ receiver.setContext(context);
- ic.pushObject(remote);
+ ic.pushObject(receiver);
}
catch (Exception ex) {
inError = true;
@@ -66,10 +66,10 @@ public class ReceiverAction extends Action {
if (inError) return;
- remote.start();
+ receiver.start();
Object o = ic.peekObject();
- if (o != remote) {
+ if (o != receiver) {
addWarn("The object at the of the stack is not the remote " +
"pushed earlier.");
} else {
--
GitLab
From 3176d1493b43a0f915ab66cdd7366d22101e5070 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 18:08:24 -0400
Subject: [PATCH 021/260] updated docs to account for receiver component type
Still needs lots of proofreading...
---
.../src/site/pages/manual/appenders.html | 211 +++++++++++-------
.../src/site/pages/manual/usingSSL.html | 89 +++-----
2 files changed, 158 insertions(+), 142 deletions(-)
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index 758c46ca9..e0793eb59 100755
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -1669,8 +1669,8 @@ public interface TriggeringPolicy<E> extends LifeCycle {
clients. Each received event is logged according to local server
policy.
-
SocketServer and its SSL-enabled counterpart
- SSLSocketServer which can be configured in the
+
ServerSocketReceiver and its SSL-enabled counterpart
+ SSLServerSocketReceiver which can be configured in the
logback.xml configuration file of any application
that uses Logback Classic, allowing any application to be a
receiver for remote logging events.
@@ -1922,19 +1922,19 @@ public interface TriggeringPolicy<E> extends LifeCycle {
the SSL configuration as aid to auditing local policy conformance.
-
Using SocketServer and SSLSocketServer
+
Using ServerSocketReceiver and SSLServerSocketReceiver
While SimpleSocketServer and
SimpleSSLSocketServer both provide an easy-to-use
standalone logging server application, you may wish instead to
integrate logging server functionality into an existing application
utilizing Logback Classic. This ability is provided by
-
- SocketServer and its SSL-enabled counterpart
-
- SSLSocketServer.
+
+ ServerSocketReceiver and its SSL-enabled counterpart
+
+ SSLServerSocketReceiver.
-
SocketServer and SSLSocketServer are
+
ServerSocketReceiver and SSLServerSocketReceiver are
components that are configured in the same manner as appenders,
loggers, and the like — by placing the appropriate configuration
properties in your application's logback.xml configuration
@@ -1942,7 +1942,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
to be a receiver for remote logging events.
-
The SocketServer component provides the following
+
The ServerSocketReceiver component provides the following
configurable properties:
@@ -1952,28 +1952,28 @@ public interface TriggeringPolicy<E> extends LifeCycle {
Description
-
address
+
address
String
The local network interface address on which the server
will listen. If this property is not specified, the server
will listen on all network interfaces.
-
port
+
port
int
The TCP port on which the server will listen. If this
property is not specified, a default value will be used.
-
ssl
+
ssl
SSLConfiguration
-
Supported only for SSLSocketServer, this
+
Supported only for SSLServerSocketReceiver, this
property provides the SSL configuration that will be used by
the server, as described in Using SSL.
-
threadPool
+
threadPool
ThreadPoolFactoryBean
This property specifies configuration for a thread pool that will
be used to manage the appender's thread resources. In most cases,
@@ -1986,11 +1986,11 @@ public interface TriggeringPolicy<E> extends LifeCycle {
For example, the following configuration uses the
- SocketServer component with a minimal appender and
+ ServerSocketReceiver component with a minimal appender and
logger configuration.
Note that the server configuration
- property identifies the server class that we wish to use. Either
- SocketServer or SSLSocketServer may be
+
Note that the receiver configuration
+ property identifies the receiver class that we wish to use. Either
+ ServerSocketReceiver or SSLServerSocketReceiver may be
specified here.
@@ -2022,12 +2022,12 @@ public interface TriggeringPolicy<E> extends LifeCycle {
path for a logback configuration file as a command line argument,
and runs the given configuration. While our example is somewhat
trivial, keep in mind that you can configure logback's
- SocketServer (and SSLSocketServer)
+ ServerSocketReceiver (and SSLServerSocketReceiver)
component in any application.
We can run our example server application as follows:
The essential differences between this configuration and the
- previous example using SocketServer are the specification
- of SSLSocketServer in the class attribute and
+ previous example using ServerSocketReceiver are the specification
+ of SSLServerSocketReceiver in the class attribute and
the presence of the nested ssl property,
which is used here to specify the location and password for the
- key store containing the server's private key and certificate, using
+ key store containing the receiver's private key and certificate, using
substitution variables. The ssl property
- of the server component accepts the same nested configuration
+ of the receiver component accepts the same nested configuration
properties as those accepted by SSLSocketAppender.
- See Using SSL for details on
- configuring the SSL properties for SSLSocketServer.
+ See Using SSL for details on
+ configuring the SSL properties for SSLServerSocketReceiver.
We can now run our SSL-enabled server configuration using the
@@ -2086,7 +2086,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
@@ -2156,9 +2156,9 @@ public interface TriggeringPolicy<E> extends LifeCycle {
connection from behind the firewall.
-
A central logging server may be using a SocketServer
+
A central logging server may be using a ServerSocketReceiver
component (or a SimpleSocketServer) to receive events from
- one or more applications using a SocketServer component.
+ one or more applications.
Events received at the central logger server could then be distributed
to interested downstream receivers using ServerSocketAppender.
The has the advantage that the central logging server may not need to
@@ -2175,13 +2175,13 @@ public interface TriggeringPolicy<E> extends LifeCycle {
The
+ SocketReceiver component (and its SSL-enabled counterpart,
+
+ SSLSocketReceiver) provide the companion client that
connects to a ServerSocketAppender. This component is
configured in logback.xml just like other logback components.
- When a configuration containing the remote component is loaded, the
+ When a configuration containing the receiver component is loaded, the
component will initiate a connection to a ServerSocketAppender
running at a remote host and port.
@@ -2243,7 +2243,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
The following configuration properties are supported by
- SocketRemote:
+ SocketReceiver:
@@ -2252,12 +2252,12 @@ public interface TriggeringPolicy<E> extends LifeCycle {
Description
-
host
+
host
String
The hostname or address of the remote server socket appender.
-
port
+
port
int
The port number of the remote server socket appender.
@@ -2271,20 +2271,20 @@ public interface TriggeringPolicy<E> extends LifeCycle {
-
ssl
+
ssl
SSLConfiguration
-
Supported only for SSLSocketRemote, this
+
Supported only for SSLSocketReceiver, this
property provides the SSL configuration that will be used for
- this remote, as described in Using SSL.
+ this receiver, as described in Using SSL.
-
Using SocketRemote with ServerSocketAppender
+
Using ServerSocketAppender and SocketReceiver
-
The configuration used for SocketRemote and
+
The configuration used for SocketReceiver and
ServerSocketAppender is conceptually similar to that used
- with SocketAppender and SocketServer. The
+ with SocketAppender and ServerSocketReceiver. The
differences relate to the fact that the roles of client
and server are reversed.
@@ -2294,8 +2294,8 @@ public interface TriggeringPolicy<E> extends LifeCycle {
The example application loads the specified configuration and then
@@ -2329,10 +2329,10 @@ public interface TriggeringPolicy<E> extends LifeCycle {
this point will be discarded by the appender.
This configuration will cause logback to connect to an
@@ -2359,46 +2359,89 @@ public interface TriggeringPolicy<E> extends LifeCycle {
(according to the configuration shown here) via a console appender. You
can configure any valid combination of appender and logger elements to
direct events received from the remote appender to an appropriate
- destination. Moreover, you can configure an any number of remote
+ destination. Moreover, you can configure an any number of receiver
components to connect to as many remote appenders as you desire.
Assuming you are in the logback-examples/ directory,
you can run this example configuration using the following command:
The example loads the configuration and then simply waits for logging
events from the remote appender. If you run this example when the remote
appender is not running, you'll see connection refused messages
- appearing in the log output, periodically. The SocketRemote
+ appearing in the log output, periodically. The SocketReceiver
component will periodically attempt to reconnect to the remote appender
until it succeeds or until the logger context is shut down. The delay
interval between attempts is configurable using the
reconnectionDelay property as shown in the
example configuration.
-
Using SSLSocketRemote with SSLServerSocketAppender
+
Using SSLServerSocketAppender and SSLSocketReceiver
- Using SSLSocketRemote is quite similar. The essential
- differences are in the class specified for the remote and the ability to
+ Using the SSL-enabled component variants is very similar. The essential
+ differences are in the class specified for the receiver and the ability to
nest the ssl property to specify SSL configuration
properties. The following example illustrates a basic configuration:
Note that the class attribute now specifies
- SSLSocketRemote and that in addition to the configuration
+ SSLSocketReceiver and that in addition to the configuration
properties shown in the previous example, this configuration contains
an SSL configuration specifying the location and password for a
trust store that will be used in validating that the remote appender is
trusted. See Using SSL for more information
- on configuring SSL properties for a remote.
+ on configuring SSL properties for a receiver.
It is important to note that our example is using a self-signed
@@ -2432,8 +2471,14 @@ public interface TriggeringPolicy<E> extends LifeCycle {
See Using SSL for more information.
-
-
+
You can run this example configuration using the following command:
Logback Classic supports the use of the Secure Sockets Layer
- (SSL) when delivering log events to a remote log server using
-
- SSLSocketAppender. This appender acts as a
- secure network client, connecting to an SSL-enabled log server
- and delivering serialized logging events over a secure channel.
- It supports all of the same logging features as the plain old
- SocketAppender while offering secure transport for
- logging events over the network.
+ (SSL) when delivering log events from a socket-based appender
+ to a remote receiver. When using An SSL-enabled appender and
+ corresponding serialized logging events are delivered over a
+ secure channel.
-
Logback Classic supports two SSL-enabled logging servers.
-
-
The
- SSLSocketServer is a logging server component
- that can be added to any Logback configuration file (e.g.
- logback.xml) to allow logging events to be
- received from a remote logger and logged according to the
- local configuration.
-
-
For those who are presently using
-
- SimpleSocketServer and simply want to start
- using SSLSocketAppender to deliver logging
- events over a secure channel, Logback Classic provides the
-
- SimpleSSLSocketServer. This server
- supports the same command line interface as the plain old
- SimpleSocketServer, while offering secure
- transport for logging events over the network.
-
-
-s
SSL and X.509 Certificates
In order to use SSL-enabled Logback components, you will need an
X.509 credential (a private key, corresponding certificate,
and CA certification chain) to identify your logging server. If
you wish to use mutual authentication, you will also need credentials
- for your Logback appender clients using SSLSocketAppender.
+ for your Logback components that act as SSL clients.
While you can use a credential issued by a commercial
certification authority (CA), you can also use a certificate issued
@@ -88,11 +62,9 @@ s
support has many configurable options, and a pluggable provider
framework that allows the built-in SSL and cryptographic
capabilities of the platform to be replaced or augmented.
- SSL-enabled Logback components such as
- SSLSocketAppender and SSLSocketServer
- provide the ability to fully specify all of the configurable
- aspects of the SSL engine and cryptographic providers, to meet
- your unique security needs.
+ SSL-enabled Logback components provide the ability to fully specify
+ all of the configurable aspects of the SSL engine and cryptographic
+ providers, to meet your unique security needs.
Basic SSL Configuration using JSSE System Properties
@@ -110,7 +82,7 @@ s
system properties to customize JSSE.
-
If you're using either the SSLSocketServer component
+
If you're using either the SSLServerSocketReceiver component
in your application's logback configuration or using the
SimpleSSLSocketServer as a standalone application
to receive logging events, you'll need to configure JSSE system
@@ -149,18 +121,17 @@ s
application via a command-line interface.
-
If your logging server is using a certificate that was
- signed by a commercial certification authority (CA), you
+
If your logback server component is using a certificate
+ that was signed by a commercial certification authority (CA), you
probably don't need to provide any SSL configuration
- in your applications that use
- SSLSocketAppender. When using a
- commercially-signed logging server certificate, simply setting
+ in your applications that SSL-enabled client components. When using
+ a commercially-signed logging server certificate, simply setting
the key store system properties in the server is usually
all that is needed.
-
If are using either a self-signed logging server certificate
- or your logging server's certificate was signed by a
+
If are using either a self-signed logback server certificate
+ or your logback server's certificate was signed by a
certification authority (CA) that is not among those whose root
certificates are in the Java platform's default trust store
(e.g. when your organization has its own internal certification
@@ -183,7 +154,7 @@ s
javax.net.ssl.trustStore
Specifies a filesystem path to the file containing your
- logging server's certificate or trusted root certificate(s)
+ logback server's certificate or trusted root certificate(s)
for the certification authority (CA) that signed.
@@ -208,7 +179,7 @@ s
Advanced SSL Configuration
In certain situations, the basic SSL configuration using
JSSE system properties is not adequate. For example, if you
- are using the SSLSocketServer component in a web
+ are using the SSLServerSocketReceiver component in a web
application, you may wish to use a different credential to
identify your logging server for your remote logging clients
than the credential that your web server uses to identify
@@ -224,7 +195,7 @@ s
specify the SSL configuration using the ssl
property in the configuration of the component.
-
For example, if you wish to use SSLSocketServer
+
For example, if you wish to use SSLServerSocketReceiver
and configure the key store properties for your logging
server's credential, you could use a configuration such as the
following.
@@ -232,7 +203,7 @@ s
View as .groovy
JSSE exposes a large number of configurable options, and
Logback's SSL support makes nearly all of them available for
- you to specify in your server or appender configuration.
+ you to specify in your SSL-enabled component configuration.
When using XML configuration, SSL properties are introduced to
- these components by nesting an <ssl> element in the appender
- or server configuration. This configuration element corresponds
+ these components by nesting an <ssl> element in the
+ component configuration. This configuration element corresponds
to the
SSLConfiguration class.
-
When configuring SSL for your server or appender components
+
When configuring SSL for your components
you need only configure those SSL properties for which the
defaults are not adequate. Overspecifying the SSL configuration
is often those cause of difficult-to-diagnose problems.
@@ -699,7 +670,7 @@ s
Set this property to the value true to
configure a server to require a valid client
certificate. This property is ignored when configured
- for a client SSLSocketAppender.
+ for a client component such as SSLSocketAppender.
@@ -709,7 +680,7 @@ s
Set this property to the value true to
configure the server to request a client
certificate. This property is ignored when configured
- for a client SSLSocketAppender.
+ for a client component such as SSLSocketAppender.
06:46:31,941 |-INFO in SSLSocketServer@4ef18d37 - SSL protocol 'SSL' provider 'SunJSSE version 1.6'
-06:46:31,967 |-INFO in SSLSocketServer@4ef18d37 - key store of type 'JKS' provider 'SUN version 1.6': file:src/main/java/chapters/appenders/socket/ssl/keystore.jks
-06:46:31,967 |-INFO in SSLSocketServer@4ef18d37 - key manager algorithm 'SunX509' provider 'SunJSSE version 1.6'
-06:46:31,973 |-INFO in SSLSocketServer@4ef18d37 - secure random algorithm 'SHA1PRNG' provider 'SUN version 1.6'
+
06:46:31,941 |-INFO in SSLServerSocketReceiver@4ef18d37 - SSL protocol 'SSL' provider 'SunJSSE version 1.6'
+06:46:31,967 |-INFO in SSLServerSocketReceiver@4ef18d37 - key store of type 'JKS' provider 'SUN version 1.6': file:src/main/java/chapters/appenders/socket/ssl/keystore.jks
+06:46:31,967 |-INFO in SSLServerSocketReceiver@4ef18d37 - key manager algorithm 'SunX509' provider 'SunJSSE version 1.6'
+06:46:31,973 |-INFO in SSLServerSocketReceiver@4ef18d37 - secure random algorithm 'SHA1PRNG' provider 'SUN version 1.6'
06:46:32,755 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled protocol: SSLv2Hello
06:46:32,755 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled protocol: SSLv3
06:46:32,755 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled protocol: TLSv1
--
GitLab
From 3828a7117d01f3de899f78dbaf93bcbe00d2d392 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 18:35:46 -0400
Subject: [PATCH 022/260] reduced timing sensitivity in
ConcurrentServerRunnerTest
---
.../server/ConcurrentServerRunnerTest.java | 25 +++++++++++--------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java
index 702fe8270..7563ad377 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java
@@ -30,6 +30,9 @@ import org.junit.Test;
public class ConcurrentServerRunnerTest {
+ private static final int DELAY = 10000;
+ private static final int SHORT_DELAY = 10;
+
private MockContext context = new MockContext();
private MockServerListener listener =
new MockServerListener();
@@ -45,8 +48,8 @@ public class ConcurrentServerRunnerTest {
@After
public void tearDown() throws Exception {
- executor.shutdown();
- assertTrue(executor.awaitTermination(2000, TimeUnit.MILLISECONDS));
+ executor.shutdownNow();
+ assertTrue(executor.awaitTermination(DELAY, TimeUnit.MILLISECONDS));
}
@Test
@@ -54,10 +57,10 @@ public class ConcurrentServerRunnerTest {
assertFalse(runner.isRunning());
executor.execute(runner);
assertTrue(runner.isRunning());
- int retries = 200;
+ int retries = DELAY / SHORT_DELAY;
synchronized (listener) {
while (retries-- > 0 && listener.getWaiter() == null) {
- listener.wait(10);
+ listener.wait(SHORT_DELAY);
}
}
assertNotNull(listener.getWaiter());
@@ -65,7 +68,7 @@ public class ConcurrentServerRunnerTest {
assertTrue(listener.isClosed());
assertFalse(runner.isRunning());
executor.shutdown();
- assertTrue(executor.awaitTermination(2000, TimeUnit.MILLISECONDS));
+ assertTrue(executor.awaitTermination(DELAY, TimeUnit.MILLISECONDS));
}
@Test
@@ -73,10 +76,10 @@ public class ConcurrentServerRunnerTest {
executor.execute(runner);
MockClient client = new MockClient();
listener.addClient(client);
- int retries = 200;
+ int retries = DELAY / SHORT_DELAY;
synchronized (client) {
while (retries-- > 0 && !client.isRunning()) {
- client.wait(10);
+ client.wait(SHORT_DELAY);
}
}
assertTrue(client.isRunning());
@@ -91,10 +94,10 @@ public class ConcurrentServerRunnerTest {
while (count-- > 0) {
MockClient client = new MockClient();
listener.addClient(client);
- int retries = 200;
+ int retries = DELAY / SHORT_DELAY;
synchronized (client) {
while (retries-- > 0 && !client.isRunning()) {
- client.wait(10);
+ client.wait(SHORT_DELAY);
}
}
assertTrue(client.isRunning());
@@ -107,10 +110,10 @@ public class ConcurrentServerRunnerTest {
executor.execute(runner);
MockClient client = new MockClient();
listener.addClient(client);
- int retries = 200;
+ int retries = DELAY / SHORT_DELAY;
synchronized (client) {
while (retries-- > 0 && !client.isRunning()) {
- client.wait(10);
+ client.wait(SHORT_DELAY);
}
}
assertTrue(client.isRunning());
--
GitLab
From 2bc16668d9c755052bf7d550e4a24555bddc79e7 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Thu, 11 Apr 2013 18:47:20 -0400
Subject: [PATCH 023/260] reduced timing sensitivity in
ConcurrentServerRunnerTest
---
.../net/server/ConcurrentServerRunner.java | 4 ++
.../server/ConcurrentServerRunnerTest.java | 45 +++++++++++++++----
2 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java b/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java
index 3047f468a..c0e37f2e3 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/server/ConcurrentServerRunner.java
@@ -78,6 +78,10 @@ public abstract class ConcurrentServerRunner
return running;
}
+ protected void setRunning(boolean running) {
+ this.running = running;
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java b/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java
index 7563ad377..7f91a121e 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/net/server/ConcurrentServerRunnerTest.java
@@ -22,6 +22,9 @@ import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import org.junit.After;
import org.junit.Before;
@@ -38,7 +41,7 @@ public class ConcurrentServerRunnerTest {
new MockServerListener();
private ExecutorService executor = Executors.newCachedThreadPool();
- private ConcurrentServerRunner runner =
+ private InstrumentedConcurrentServerRunner runner =
new InstrumentedConcurrentServerRunner(listener, executor);
@Before
@@ -56,7 +59,7 @@ public class ConcurrentServerRunnerTest {
public void testStartStop() throws Exception {
assertFalse(runner.isRunning());
executor.execute(runner);
- assertTrue(runner.isRunning());
+ assertTrue(runner.awaitRunState(true, DELAY));
int retries = DELAY / SHORT_DELAY;
synchronized (listener) {
while (retries-- > 0 && listener.getWaiter() == null) {
@@ -66,9 +69,7 @@ public class ConcurrentServerRunnerTest {
assertNotNull(listener.getWaiter());
runner.stop();
assertTrue(listener.isClosed());
- assertFalse(runner.isRunning());
- executor.shutdown();
- assertTrue(executor.awaitTermination(DELAY, TimeUnit.MILLISECONDS));
+ assertFalse(runner.awaitRunState(false, DELAY));
}
@Test
@@ -82,7 +83,7 @@ public class ConcurrentServerRunnerTest {
client.wait(SHORT_DELAY);
}
}
- assertTrue(client.isRunning());
+ assertTrue(runner.awaitRunState(true, DELAY));
client.close();
runner.stop();
}
@@ -100,7 +101,7 @@ public class ConcurrentServerRunnerTest {
client.wait(SHORT_DELAY);
}
}
- assertTrue(client.isRunning());
+ assertTrue(runner.awaitRunState(true, DELAY));
}
runner.stop();
}
@@ -116,7 +117,7 @@ public class ConcurrentServerRunnerTest {
client.wait(SHORT_DELAY);
}
}
- assertTrue(client.isRunning());
+ assertTrue(runner.awaitRunState(true, DELAY));
MockClientVisitor visitor = new MockClientVisitor();
runner.accept(visitor);
assertSame(client, visitor.getLastVisited());
@@ -127,6 +128,9 @@ public class ConcurrentServerRunnerTest {
static class InstrumentedConcurrentServerRunner
extends ConcurrentServerRunner {
+ private final Lock lock = new ReentrantLock();
+ private final Condition runningCondition = lock.newCondition();
+
public InstrumentedConcurrentServerRunner(
ServerListener listener, Executor executor) {
super(listener, executor);
@@ -137,6 +141,31 @@ public class ConcurrentServerRunnerTest {
return true;
}
+ @Override
+ protected void setRunning(boolean running) {
+ lock.lock();
+ try {
+ super.setRunning(running);
+ runningCondition.signalAll();
+ }
+ finally {
+ lock.unlock();
+ }
+ }
+
+ public boolean awaitRunState(boolean state,
+ long delay) throws InterruptedException {
+ lock.lock();
+ try {
+ while (isRunning() != state) {
+ runningCondition.await(delay, TimeUnit.MILLISECONDS);
+ }
+ return isRunning();
+ }
+ finally {
+ lock.unlock();
+ }
+ }
}
}
--
GitLab
From 2492ad3b2dfcb735ad145bf811329b8b4e9e8b01 Mon Sep 17 00:00:00 2001
From: Ceki Gulcu
Date: Fri, 12 Apr 2013 08:49:14 +0200
Subject: [PATCH 024/260] typo fix
---
logback-site/src/site/pages/manual/configuration.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/logback-site/src/site/pages/manual/configuration.html b/logback-site/src/site/pages/manual/configuration.html
index ccf1b9f72..9530c49fa 100755
--- a/logback-site/src/site/pages/manual/configuration.html
+++ b/logback-site/src/site/pages/manual/configuration.html
@@ -478,7 +478,7 @@ public class Foo {
ReconfigureOnChangeFilter is in reality "alive" only
once every N logging operations. Depending on how often
your application logs, the value of N can be modified on
- the fly by logback. By default N is 16, altough it can go as high
+ the fly by logback. By default N is 16, although it can go as high
as 2^16 (= 65536) for CPU-intensive applications.
--
GitLab
From 69a1c3af76789bbe50f2cbb1d3fcf81e20f56481 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Sat, 13 Apr 2013 17:43:14 -0400
Subject: [PATCH 025/260] discussion of receiver components moved to a separate
chapter
The Appenders chapter had become quite long due to the inclusion
of the documentation of Receiver components.
---
.../src/site/pages/manual/appenders.html | 455 ++-------------
.../src/site/pages/manual/receivers.html | 526 ++++++++++++++++++
2 files changed, 559 insertions(+), 422 deletions(-)
create mode 100644 logback-site/src/site/pages/manual/receivers.html
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index e0793eb59..4260654eb 100755
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -1660,20 +1660,21 @@ public interface TriggeringPolicy<E> extends LifeCycle {
for servers that can be used to receive logging events from
SocketAppender or SSLSocketAppender.
+
ServerSocketReceiver and its SSL-enabled
+ counterpart SSLServerSocketReceiver are receiver
+ components which can be configured in the logback.xml
+ configuration file of an application in order receive events
+ from a remote socket appender. See
+ Receivers for configuration details and usage examples.
+
SimpleSocketServer and its SSL-enabled counterpart
- SimpleSSLSocketServer, which both offer an
+ SimpleSSLSocketServer both offer an
easy-to-use standalone Java application that is designed to
be configured and run from your shell's command line interface.
These applications simply wait for logging events from
SocketAppender or SSLSocketAppender
clients. Each received event is logged according to local server
- policy.
-
-
ServerSocketReceiver and its SSL-enabled counterpart
- SSLServerSocketReceiver which can be configured in the
- logback.xml configuration file of any application
- that uses Logback Classic, allowing any application to be a
- receiver for remote logging events.
+ policy. Usage examples are given below.
@@ -1922,191 +1923,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
the SSL configuration as aid to auditing local policy conformance.
-
Using ServerSocketReceiver and SSLServerSocketReceiver
-
While SimpleSocketServer and
- SimpleSSLSocketServer both provide an easy-to-use
- standalone logging server application, you may wish instead to
- integrate logging server functionality into an existing application
- utilizing Logback Classic. This ability is provided by
-
- ServerSocketReceiver and its SSL-enabled counterpart
-
- SSLServerSocketReceiver.
-
-
-
ServerSocketReceiver and SSLServerSocketReceiver are
- components that are configured in the same manner as appenders,
- loggers, and the like — by placing the appropriate configuration
- properties in your application's logback.xml configuration
- file. This allows any application using Logback Classic
- to be a receiver for remote logging events.
-
-
-
The ServerSocketReceiver component provides the following
- configurable properties:
-
-
-
-
Property Name
-
Type
-
Description
-
-
-
address
-
String
-
The local network interface address on which the server
- will listen. If this property is not specified, the server
- will listen on all network interfaces.
-
-
-
port
-
int
-
The TCP port on which the server will listen. If this
- property is not specified, a default value will be used.
-
-
-
ssl
-
SSLConfiguration
-
Supported only for SSLServerSocketReceiver, this
- property provides the SSL configuration that will be used by
- the server, as described in Using SSL.
-
-
-
-
threadPool
-
ThreadPoolFactoryBean
-
This property specifies configuration for a thread pool that will
- be used to manage the appender's thread resources. In most cases,
- this configuration is not required, as the defaults are generally
- adequate. See
- ThreadPoolFactoryBean for a description of the
- configurable properties and recommended settings.
-
-
-
-
-
For example, the following configuration uses the
- ServerSocketReceiver component with a minimal appender and
- logger configuration.
-
Note that the receiver configuration
- property identifies the receiver class that we wish to use. Either
- ServerSocketReceiver or SSLServerSocketReceiver may be
- specified here.
-
-
-
Our example server application is very similar in function and
- design to SimpleSocketServer. It simply accepts a
- path for a logback configuration file as a command line argument,
- and runs the given configuration. While our example is somewhat
- trivial, keep in mind that you can configure logback's
- ServerSocketReceiver (and SSLServerSocketReceiver)
- component in any application.
-
-
-
We can run our example server application as follows:
The essential differences between this configuration and the
- previous example using ServerSocketReceiver are the specification
- of SSLServerSocketReceiver in the class attribute and
- the presence of the nested ssl property,
- which is used here to specify the location and password for the
- key store containing the receiver's private key and certificate, using
- substitution variables. The ssl property
- of the receiver component accepts the same nested configuration
- properties as those accepted by SSLSocketAppender.
- See Using SSL for details on
- configuring the SSL properties for SSLServerSocketReceiver.
-
-
-
We can now run our SSL-enabled server configuration using the
- same example server application, by specifying values for the
- substitution variables in our configuration and referencing the
- appropriate configuration file:
Note that the keystore property given on the command
- line specifies a file URL that identifies the location of the key
- store. You may also use a classpath URL as described in
- Using SSL.
-
-
-
Also we must point out once again that our example X.509
- credential is suitable for testing and experimentation, only.
- In a production setting, you should obtain an appropriate
- X.509 credential to identify your logging server. See Using SSL for more information.
-
-
Once our server is started, we can connect to it just as shown in
- the previous examples for using
- SimpleSSLSocketServer.
-
-
+
ServerSocketAppender and SSLServerSocketAppender
@@ -2144,47 +1961,12 @@ public interface TriggeringPolicy<E> extends LifeCycle {
of connection initiation is reversed. While SocketAppender
acts as the active peer in establishing the connection to a logging server,
ServerSocketAppender is passive; it listens for
- incoming connections from clients. This difference is especially useful
- in situations such as the following:
-
-
-
For security reasons, a central logging server may be
- located behind a network firewall that does not allow incoming
- connections. Using a ServerSocketAppender component, an
- application that wishes to deliver events to the central
- logger can passively wait for the central logger to initiate the
- connection from behind the firewall.
-
-
-
A central logging server may be using a ServerSocketReceiver
- component (or a SimpleSocketServer) to receive events from
- one or more applications.
- Events received at the central logger server could then be distributed
- to interested downstream receivers using ServerSocketAppender.
- The has the advantage that the central logging server may not need to
- be configured for each new downstream receiver. The central logging
- serve thus acts as a hub, receiving logging events from applications
- and distributing them to interested clients.
-
This is particularly relevant for developer tools such as IDE
- plugins or enterprise management tools that might want to receive
- events from server-based applications for local display, filtering,
- and alerting. Arranging for the central server to initiate a
- connection to such tools may prove difficult, particularly when the
- tool is running on a developer's workstation, which may indeed be
- mobile.
-
-
+ incoming connections from clients.
-
The
- SocketReceiver component (and its SSL-enabled counterpart,
-
- SSLSocketReceiver) provide the companion client that
- connects to a ServerSocketAppender. This component is
- configured in logback.xml just like other logback components.
- When a configuration containing the receiver component is loaded, the
- component will initiate a connection to a ServerSocketAppender
- running at a remote host and port.
-
+
The ServerSocketAppender subtypes are intended to be
+ used exclusively with Logback receiver components. See
+ Receivers for additional information on
+ this component type.
The following configuration properties are supported by
ServerSocketAppender:
The following configuration properties are supported by
- SocketReceiver:
-
-
-
-
Property Name
-
Type
-
Description
-
-
-
host
-
String
-
The hostname or address of the remote server socket appender.
-
-
-
port
-
int
-
The port number of the remote server socket appender.
-
-
-
reconnectionDelay
-
int
-
- A positive integer representing the number of milliseconds to wait
- before attempting to reconnect after a connection failure. The
- default value is 30000 (30 seconds).
-
-
-
-
ssl
-
SSLConfiguration
-
Supported only for SSLSocketReceiver, this
- property provides the SSL configuration that will be used for
- this receiver, as described in Using SSL.
-
-
-
-
-
Using ServerSocketAppender and SocketReceiver
-
-
The configuration used for SocketReceiver and
- ServerSocketAppender is conceptually similar to that used
- with SocketAppender and ServerSocketReceiver. The
- differences relate to the fact that the roles of client
- and server are reversed.
-
-
The following example illustrates a configuration that uses
- ServerSocketAppender:
+ ServerSocketAppender:
The example application loads the specified configuration and then
- prompts the user to enter messages which will be relayed to connected
- clients. Since there are no client connections, yet, messages entered at
- this point will be discarded by the appender.
-
The following example illustrates a configuration using
+ SSLServerSocketAppender.
-
This configuration will cause logback to connect to an
- ServerSocketAppender running on the host and port specified
- by the host and port substitution variables. Logging
- events received from the remote appender will be logged locally
- (according to the configuration shown here) via a console appender. You
- can configure any valid combination of appender and logger elements to
- direct events received from the remote appender to an appropriate
- destination. Moreover, you can configure an any number of receiver
- components to connect to as many remote appenders as you desire.
-
-
-
Assuming you are in the logback-examples/ directory,
- you can run this example configuration using the following command:
The example loads the configuration and then simply waits for logging
- events from the remote appender. If you run this example when the remote
- appender is not running, you'll see connection refused messages
- appearing in the log output, periodically. The SocketReceiver
- component will periodically attempt to reconnect to the remote appender
- until it succeeds or until the logger context is shut down. The delay
- interval between attempts is configurable using the
- reconnectionDelay property as shown in the
- example configuration.
-
-
Using SSLServerSocketAppender and SSLSocketReceiver
-
- Using the SSL-enabled component variants is very similar. The essential
- differences are in the class specified for the receiver and the ability to
- nest the ssl property to specify SSL configuration
- properties. The following example illustrates a basic configuration:
-
-
-
The following example illustrates a configuration that uses
- SSLServerSocketAppender:
-
Note that the class attribute now specifies
- SSLSocketReceiver and that in addition to the configuration
- properties shown in the previous example, this configuration contains
- an SSL configuration specifying the location and password for a
- trust store that will be used in validating that the remote appender is
- trusted. See Using SSL for more information
- on configuring SSL properties for a receiver.
-
-
-
It is important to note that our example is using a self-signed
- X.509 credential that suitable for testing and experimentation, only.
- In a production setting, you should obtain an appropriate
- X.509 credential to identify your trusted appender components.
- See Using SSL for more information.
-
-
-
You can run this example configuration using the following command:
The principal differences between this configuration and the
+ previous configuration is that the appender's class attribute
+ identifies the SSLServerSocketAppender type, and the
+ presence of the nested ssl element which
+ specifies, in this example, configuration of a key store containing
+ an X.509 credential for the appender. See
+ Using SSL for information regarding SSL configuration properties.
+
+
+
Because the ServerSocketAppender subtypes wait
+ passively for a connection from interested receivers, we will defer
+ presenting illustrative examples to the chapter entitled
+ Receivers.
A receiver is a Logback component that receives logging
+ events from a remote appender and logs each received event according
+ to local policy. Using a combination of socket-based appenders and
+ receivers, it is possible to construct sophisticated topologies
+ for distribution of application logging events.
Traditionally, a SocketAppender has acted as a
+ client, connecting to a standalone SimpleSocketServer
+ application acting as a server. The receiver component offers much
+ greater flexibility.
+
+
A receiver component is configured in logback.xml, just
+ like any other logback component. This allows the full capabilities
+ of Joran to be utilized in configuring
+ a receiver component. Moreover, any application can
+ receive logging events from remote appenders by simply configuring
+ one or more receiver components.
+
+
Connection initiation between an appender and a receiver
+ can occur in either direction. A receiver can act in the role of a
+ server, passively listening for connections from remote appender
+ clients. Alternatively, a receiver can act in the client role,
+ initiating a connection to a remote appender which is acting in the
+ server role. Regardless of the respective roles of the
+ appender and receiver, logging events always flow from
+ the appender towards the receiver.
+
+
This flexibility to allow a receiver to initiate the connection
+ to a logback appender is particularly useful in certain situations:
+
+
+
For security reasons, a central logging server may be
+ located behind a network firewall that does not allow incoming
+ connections. Using receiver components acting in the client
+ role, the central logging server (inside the firewall)
+ can initiate connections to the applications of interest
+ (outside the firewall).
+
+
It is often desirable for developer tools (such as IDE plugins)
+ and enterprise management applications to have access to the
+ logging event stream of running applications. Traditionally,
+ Logback has supported this (for example in Logback Beagle) by
+ requiring the receiving application to act in the server role,
+ passively listening for connections a remote appender. This
+ can prove difficult to manage, especially for tools running on
+ a developer's workstation, which may indeed by mobile. However,
+ such tools can now be implemented using a Logback receiver
+ component acting in the client role, initiating a connection to
+ a remote appender in order to receive logging events for local
+ display, filtering, and alerting.
+
+
+
+
A logback configuration can include any number of receiver components
+ acting in any combination of the server or client roles. The only
+ restrictions are that each receiver acting in the server role must
+ listen on a distinct port, and each receiver acting in the client
+ role will connect to exactly one remote appender.
+
+
+ Receivers that Act in the Server Role
+
+
A receiver that is configured to act in the server role passively
+ listens for incoming connections from remote appenders. This is
+ functionally equivalent to the traditional
+ SimpleSocketServer application, except that by using
+ the receiver component, any application that uses Logback
+ Classic can receive logging events from remote appenders by simply
+ configuring the receiver in logback.xml like any other
+ logback component.
+
+
Logback includes two receiver components that act in the server
+ role;
+ ServerSocketReceiver and its SSL-enabled subtype
+
+ SSLServerSocketReceiver. Both of these receiver
+ components are designed to accept connections from incoming
+ SocketAppender (or SSLSocketAppender)
+ clients.
+
+
The ServerSocketReceiver components provide the
+ following configurable properties:
+
+
+
+
Property Name
+
Type
+
Description
+
+
+
address
+
String
+
The local network interface address on which the server
+ will listen. If this property is not specified, the server
+ will listen on all network interfaces.
+
+
+
port
+
int
+
The TCP port on which the server will listen. If this
+ property is not specified, a default value will be used.
+
+
+
ssl
+
SSLConfiguration
+
Supported only for SSLServerSocketReceiver, this
+ property provides the SSL configuration that will be used by
+ the server, as described in Using SSL.
+
+
+
+
threadPool
+
ThreadPoolFactoryBean
+
This property specifies configuration for a thread pool that will
+ be used to manage the appender's thread resources. In most cases,
+ this configuration is not required, as the defaults are generally
+ adequate. See
+ ThreadPoolFactoryBean for a description of the
+ configurable properties and recommended settings.
+
+
+
+
+
+ Using ServerSocketReceiver
+
+
The following configuration uses the
+ ServerSocketReceiver component with a minimal local
+ appender and logger configuration. Logging events received from
+ a remote appender will be matched by the root logger and delivered
+ to the local console appender.
Note that the receiver component's class
+ attribute identifies the receiver subtype that we wish to use. In
+ this example we are using ServerSocketReceiver.
+
+
Our example server application is very similar in function and
+ design to SimpleSocketServer. It simply accepts a
+ path for a logback configuration file as a command line argument,
+ and runs the given configuration. While our example is somewhat
+ trivial, keep in mind that you can configure logback's
+ ServerSocketReceiver (or SSLServerSocketReceiver)
+ component in any application.
+
+
+
From a shell in the logback-examples directory,
+ we can run our example server application as follows:
We can connect to the running receiver using a client application
+ that is configured with a SocketAppender. Our example
+ client application simply loads a logback configuration that will
+ connect a socket appender to our example receiver. It then awaits
+ input from the user in the form of a message that will be relayed to
+ the receiver. We can run the example client application as follows:
+
The following configuration repeats the same minimal appender
+ and logger configuration, but uses the SSL-enabled receiver component
+ that acts in the server role.
The essential differences between this configuration and the
+ previous example using ServerSocketReceiver are the
+ specification of SSLServerSocketReceiver in the
+ class attribute and the presence of the nested
+ ssl property, which is used here to
+ specify the location and password for the key store containing the
+ receiver's private key and certificate, using substitution variables.
+ See Using SSL for details on
+ configuring SSL properties for Logback components.
+
+
We can run this configurtation using the same example server
+ configuration, with just a couple of additional configuration
+ properties:
Note that the keystore property given on the command
+ line specifies a file URL that identifies the location of the key
+ store. You may also use a classpath URL as described in
+ Using SSL.
+
+
+
Also we must point out that our example X.509
+ credential is suitable for testing and experimentation, only.
+ In a production setting, you should obtain an appropriate
+ X.509 credential to identify your SSL-enabled logback components.
+ See Using SSL for more information.
+
+
We can connect to the running receiver using a client application
+ that is configured with a SSLSocketAppender. Our example
+ client application simply loads a logback configuration that will
+ connect a socket appender to our example receiver. It then awaits
+ input from the user in the form of a message that will be relayed to
+ the receiver. We can run the example client application as follows:
+
A receiver that is configured to act in the client role initiates
+ a connection to a remote appender. The remote appender must be a
+ server type, such as ServerSocketAppender.
+
+
Logback includes two receiver components that act in the client
+ role;
+ SocketReceiver and its SSL-enabled subtype
+
+ SSLSocketReceiver. Both of these receiver
+ components are designed to initiate a connection to a remote appender
+ that is a ServerSocketAppender
+ (or SSLServerSocketAppender).
+
+
The following configuration properties are supported by
+ SocketReceiver subtypes:
+
+
+
+
Property Name
+
Type
+
Description
+
+
+
host
+
String
+
The hostname or address of the remote server socket appender.
+
+
+
port
+
int
+
The port number of the remote server socket appender.
+
+
+
reconnectionDelay
+
int
+
+ A positive integer representing the number of milliseconds to wait
+ before attempting to reconnect after a connection failure. The
+ default value is 30000 (30 seconds).
+
+
+
+
ssl
+
SSLConfiguration
+
Supported only for SSLSocketReceiver, this
+ property provides the SSL configuration that will be used for
+ this receiver, as described in Using SSL.
+
+
+
+
+
+ Using SocketReceiver
+
+
The configuration used for SocketReceiver
+ is quite similar to the previous example that used
+ ServerSocketReceiver. The differences relate to the
+ fact that the roles of client and server are reversed; a receiver
+ of type SocketReceiver is a client, and the remote
+ appender acts as a server.
This configuration will cause logback to connect to an
+ ServerSocketAppender running on the host and port specified
+ by the host and port substitution variables. Logging
+ events received from the remote appender will be logged locally
+ (according to the configuration shown here) via a console appender.
+
+
+
Assuming you are in the logback-examples/ directory,
+ you can run this example configuration using the following command:
The example loads the configuration and then simply waits for logging
+ events from the remote appender. If you run this example when the remote
+ appender is not running, you'll see connection refused messages
+ appearing in the log output, periodically. The SocketReceiver
+ component will periodically attempt to reconnect to the remote appender
+ until it succeeds or until the logger context is shut down. The delay
+ interval between attempts is configurable using the
+ reconnectionDelay property as shown in the
+ example configuration.
+
+
We can provide a remote appender to which our example receiver
+ can connect, using the same appender example used previously. The
+ example loads a logback configuration containing a
+ ServerSocketAppender, and then waits input from the
+ user consisting of a message that will be delivered to connected
+ receivers. We can run the example appender application as follows:
+
+ The configuration needed the SSLSocketReceiver is very
+ similar to that used with SocketReceiver. The essential
+ differences are in the class specified for the receiver and the ability
+ to nest the ssl property to specify SSL
+ configuration properties. The following example illustrates a basic
+ configuration:
+
Note that the class attribute now specifies
+ SSLSocketReceiver and that in addition to the configuration
+ properties shown in the previous example, this configuration contains
+ an SSL configuration specifying the location and password for a
+ trust store that will be used in validating that the remote appender is
+ trusted. See Using SSL for more information
+ on configuring SSL properties.
+
+
+
It is important to note once again, that our example is using a
+ self-signed X.509 credential that suitable for testing and
+ experimentation, only. In a production setting, you should
+ obtain an appropriate X.509 credential to identify your SSL-enabled
+ logback components. See Using SSL
+ for more information.
+
+
You can run this example configuration using the following command:
Once started, the receiver attempts to connect to the specified
+ remote appender. Assuming that the appender is not yet running, you
+ will see a "connection refused" message appearing in the log output
+ periodically; the receiver will periodically retry the connection to
+ the remote appender after delaying for the period of time specified by
+ the reconnectionDelay property.
+
+
+
We can provide a remote appender to which our example receiver
+ can connect, using the same appender example used previously. The
+ example loads a logback configuration containing a
+ SSLServerSocketAppender, and then awaits input from the
+ user consisting of a message that will be delivered to connected
+ receivers. We can run the example appender application as follows:
+
Logback Classic supports the use of the Secure Sockets Layer
+
Chapter 15: Using SSL
+
+
+
+
The whole difference between construction and creation is
+ exactly this: that a thing constructed can only be loved after it
+ is constructed; but a thing created is loved before it exists.
+
—CHARLES DICKENS
+
+
+
+
+
+
+
+
Logback supports the use of the Secure Sockets Layer
(SSL) when delivering log events from a socket-based appender
- to a remote receiver. When using An SSL-enabled appender and
- corresponding serialized logging events are delivered over a
- secure channel.
+ to a remote receiver. When using an SSL-enabled appender and
+ corresponding receiver, serialized logging events are delivered
+ over a secure channel.
SSL and X.509 Certificates
In order to use SSL-enabled Logback components, you will need an
X.509 credential (a private key, corresponding certificate,
- and CA certification chain) to identify your logging server. If
- you wish to use mutual authentication, you will also need credentials
- for your Logback components that act as SSL clients.
+ and CA certification chain) to identify your Logback components
+ that act as SSL servers. If you wish to use mutual authentication,
+ you will also need credentials for your Logback components that
+ act as SSL clients.
While you can use a credential issued by a commercial
certification authority (CA), you can also use a certificate issued
@@ -46,13 +61,14 @@
following is all that is required:
-
The server must be configured with a key store containing
- the server's private key, corresponding certificate, and
- CA certification chain (if not using a self-signed certificate).
+
The component acting in the server role must be configured
+ with a key store containing the server's private key,
+ corresponding certificate, and CA certification chain
+ (if not using a self-signed certificate).
-
The client must be configured with a trust store containing
- the trusted root CA certificate(s) or the server's
- signed root certificate.
+
The component acting in the client role must be configured
+ with a trust store containing trusted root CA
+ certificate(s) or the server's self-signed root certificate.
@@ -82,13 +98,13 @@
system properties to customize JSSE.
-
If you're using either the SSLServerSocketReceiver component
- in your application's logback configuration or using the
- SimpleSSLSocketServer as a standalone application
- to receive logging events, you'll need to configure JSSE system
- properties that provide the location, type, and password
- of the key store containing the private key and certificate for
- your logging server.
+
If you're using any of logback's SSL-enabled appender or receiver
+ components that act in the server role (e.g.
+ SSLServerSocketReceiver, ServerSocketAppender,
+ or SimpleSSLSocketServer) you'll need to configure
+ JSSE system properties that provide the location, type, and
+ password of the key store containing a private key and
+ certificate.
@@ -101,7 +117,7 @@
javax.net.ssl.keyStore
Specifies a filesystem path to the file containing your
- logging server's private key and certificate.
+ server components's private key and certificate.
javax.net.ssl.keyStoreType
@@ -124,14 +140,14 @@
If your logback server component is using a certificate
that was signed by a commercial certification authority (CA), you
probably don't need to provide any SSL configuration
- in your applications that SSL-enabled client components. When using
- a commercially-signed logging server certificate, simply setting
- the key store system properties in the server is usually
- all that is needed.
+ in your applications that SSL-enabled client components.
+ When using a commercially-signed certificate for your server
+ component, simply setting the system key store properties for JVM
+ that runs the server component is usually all that is needed.
If are using either a self-signed logback server certificate
- or your logback server's certificate was signed by a
+ or your logback server certificate was signed by a
certification authority (CA) that is not among those whose root
certificates are in the Java platform's default trust store
(e.g. when your organization has its own internal certification
@@ -154,8 +170,9 @@
javax.net.ssl.trustStore
Specifies a filesystem path to the file containing your
- logback server's certificate or trusted root certificate(s)
- for the certification authority (CA) that signed.
+ logback server component's certificate or trusted root
+ certificate(s) for the certification authority (CA) that
+ signed the server certificate.
javax.net.ssl.trustStoreType
@@ -727,15 +744,16 @@
Examples
-
Creating and Using a Self-Signed Logging Server Credential
+
Creating and Using a Self-Signed Server Component Credential
To generate a self-signed certificate, you can use the keytool
utility that is shipped with the Java Runtime Environment (JRE).
The instructions below walk through the process of creating a
- self-signed X.509 credential in a key store for your logging server
- and creating a trust store for use with your appender clients.
+ self-signed X.509 credential in a key store for your server
+ component and creating a trust store for use with your client
+ components.
-
Creating the logging server credential:
+
Creating the server component credential:
The following command will generate the self-signed client
credential in a file named server.keystore.
keytool -genkey -alias server -dname "CN=my-logging-server" \
@@ -748,7 +766,7 @@ Enter key password for <my-logging-server>
The name my-logging-server used in the dname
may be any valid name of your choosing. You may wish to use the
- fully-qualified domain name of the logging server host. The
+ fully-qualified domain name of the server host. The
validity argument specifies the number of calendar days
from the present date until the credential expires.
@@ -757,11 +775,11 @@ Enter key password for <my-logging-server>
This password protects the server's private key, preventing it
from being used by an authorized party. Make note of the
password, because you will need it in subsequent steps and when
- configuring your logging server.
+ configuring your server.
-
Creating a trust store for appender clients:
-
For use in the configuration of your appender clients, the
+
Creating a trust store for client components:
+
For use in the configuration of your client components, the
server's certificate needs to be exported from the key store
created in the previous step, and imported into a trust store. The
following commands will export the certificate and import it into
@@ -797,7 +815,7 @@ Trust this certificate? [no]: <Enter "yes">
clients.
-
Configuring the logging server:
+
Configuring the server component:
You will need to copy the server.keystore file into your
server application's configuration. The key store can be placed
with your application's classpath resources, or it may simply be
@@ -806,7 +824,7 @@ Trust this certificate? [no]: <Enter "yes">
either a classpath: URL or file: URL, as
appropriate. A example server configuration follows:
-
Example: Logging Server Configuration
+
Example: Server Component Configuration
<configuration debug="true">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
@@ -840,15 +858,14 @@ Trust this certificate? [no]: <Enter "yes">
using the entered password before configuring the logging system.
-
Configuring appender clients:
+
Configuring client components:
You will need to copy the server.truststore file into
- the application configuration of each application that uses
- SSLSocketAppender to send logging events to your
- server. The trust store can be placed with your application's
- classpath resources, or it may simply be placed somewhere on the
- filesystem. When specifying the location of the trust
- store in the configuration, you will use either a
- classpath: URL or file: URL, as
+ the application configuration of each application that uses an
+ SSL-enabled component acting in the client mode. The trust store
+ can be placed with your application's classpath resources, or it
+ may simply be placed somewhere on the filesystem. When specifying
+ the location of the trust store in the configuration, you will use
+ either a classpath: URL or file: URL, as
appropriate. A example appender client configuration follows:
Example: Appender Client Configuration
@@ -929,24 +946,23 @@ Trust this certificate? [no]: <Enter "yes">
Resolving SSL Exceptions
-
When using SSLSocketAppender, the appender acts
- as a client, connecting to an SSL-enabled logging server.
- If SSL is misconfigured, it generally results in the client
- and server being unable to negotiate an agreeable session. This
- problem usually manifests itself as exceptions being thrown by
- both parties when the client attempts to connect to the server.
+
When SSL is misconfigured, it generally results in the client
+ and server components being unable to negotiate an agreeable
+ session. This problem usually manifests itself as exceptions
+ being thrown by both parties when the client attempts to connect
+ to the server.
The content of the exception messages varies depending on whether
you are looking at the client's log or the server's log. This
is mostly due to inherent protocol limitations in error reporting
during session negotiation. As a consequence of this fact,
in order to troubleshoot session negotiation problems, you will
- usually want to look at the logs of both the appender client
- and the logging server.
+ usually want to look at the logs of both the client and the
+ server.
Server's Certificate is Not Available
-
When starting the logging server, you
+
When starting the server component, you
see the following exception in the log:
javax.net.ssl.SSLException: No available certificate or
@@ -969,9 +985,9 @@ Trust this certificate? [no]: <Enter "yes">
Client Does Not Trust the Server
-
When the appender client attempts to connect to the logging
- server, you see the following exception in the log:
-
+
When the client attempts to connect to the server, you see the
+ following exception in the log:
+
javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException:
PKIX path building failed
@@ -1039,7 +1055,7 @@ Trust this certificate? [no]: <Enter "yes">
certificate_expired or certificate_revoked
the server needs a new certificate. The new certificate
and associated private key needs to be placed in the key store
- specified in the logging server's configuration. And, if using
+ specified in the server's configuration. And, if using
a self-signed server certificate, the server's certificate also
needs to be placed in the trust store specified in the appender
client's configuration.
@@ -1053,7 +1069,7 @@ Trust this certificate? [no]: <Enter "yes">
property).
-
When the appender client attempts to connect to the logging
+
When the client attempts to connect to the logging
server, you see the following exception in the client's log:
@@ -1106,9 +1122,9 @@ Trust this certificate? [no]: <Enter "yes">
certificate_expired or certificate_revoked
the client needs a new certificate. The new certificate
and associated private key needs to be placed in the key store
- specified in the appender client's configuration. And, if using
+ specified in the client's configuration. And, if using
a self-signed client certificate, the client's certificate also
- needs to be placed in the trust store specified in the logging
+ needs to be placed in the trust store specified in the
servers's configuration.
@@ -1120,9 +1136,8 @@ Trust this certificate? [no]: <Enter "yes">
protocols in your configuration.
-
When the appender client attempts to connect to the logging
- server, you see the following exception in the log:
-
+
When the client attempts to connect to the server, you see
+ the following exception in the log:
javax.net.ssl.SSLHandshakeException: Received fatal
alert: handshake_failure
@@ -1141,7 +1156,7 @@ Trust this certificate? [no]: <Enter "yes">
Check the values specified for the
excludedProtocols and
includedProtocols
- properties on both the logging server and appender client.
+ properties on both the server and client.
Client and Server Cannot Agree on a Cipher Suite
@@ -1152,7 +1167,7 @@ Trust this certificate? [no]: <Enter "yes">
cipher suites in your configuration.
-
When the appender client attempts to connect to the logging
+
When the client attempts to connect to the
server, you see the following exception in the log:
@@ -1167,7 +1182,7 @@ Trust this certificate? [no]: <Enter "yes">
This means that you have configured the cipher suites on the
- logging server and appender client such that the intersection
+ server and client such that the intersection
of their respective sets of enabled cipher suites is empty.
Solution
--
GitLab
From ad1c10da40a4650c6408d40e41f1633928e147e5 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Sat, 13 Apr 2013 17:45:10 -0400
Subject: [PATCH 027/260] added references to chapters on receivers and SSL
configuration
Probably want to consider inserting the chapter on receivers
somewhere near the middle...
---
logback-site/src/site/pages/manual/index.html | 8 ++++++++
logback-site/src/site/pages/manual/menu.js | 2 ++
2 files changed, 10 insertions(+)
diff --git a/logback-site/src/site/pages/manual/index.html b/logback-site/src/site/pages/manual/index.html
index 52c7c1332..36577f4e5 100644
--- a/logback-site/src/site/pages/manual/index.html
+++ b/logback-site/src/site/pages/manual/index.html
@@ -112,6 +112,14 @@
Chapter 13: Migration from log4j
+
');
--
GitLab
From 14556a699fba289f89596b2e777d8714d294236c Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Sun, 14 Apr 2013 08:06:16 -0400
Subject: [PATCH 028/260] moved examples of receiver usage from appenders
examples
---
.../socket/ServerSocketReceiver1.java | 55 -------------------
.../chapters/appenders/socket/ssl/client.xml | 2 +-
.../chapters/appenders/socket/ssl/client2.xml | 34 ------------
.../socket/ssl/{server1.xml => server.xml} | 2 +-
.../chapters/appenders/socket/ssl/server2.xml | 32 -----------
.../chapters/appenders/socket/ssl/server3.xml | 28 ----------
.../socket/AppenderExample.java} | 0
.../socket/ReceiverExample.java} | 0
.../socket/appender1.xml} | 0
.../socket/receiver1.xml} | 0
10 files changed, 2 insertions(+), 151 deletions(-)
delete mode 100644 logback-examples/src/main/java/chapters/appenders/socket/ServerSocketReceiver1.java
delete mode 100644 logback-examples/src/main/java/chapters/appenders/socket/ssl/client2.xml
rename logback-examples/src/main/java/chapters/appenders/socket/ssl/{server1.xml => server.xml} (96%)
delete mode 100644 logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml
delete mode 100644 logback-examples/src/main/java/chapters/appenders/socket/ssl/server3.xml
rename logback-examples/src/main/java/chapters/{appenders/socket/ServerSocketAppender1.java => receivers/socket/AppenderExample.java} (100%)
rename logback-examples/src/main/java/chapters/{appenders/socket/SocketReceiver1.java => receivers/socket/ReceiverExample.java} (100%)
rename logback-examples/src/main/java/chapters/{appenders/socket/server4.xml => receivers/socket/appender1.xml} (100%)
rename logback-examples/src/main/java/chapters/{appenders/socket/server3.xml => receivers/socket/receiver1.xml} (100%)
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ServerSocketReceiver1.java b/logback-examples/src/main/java/chapters/appenders/socket/ServerSocketReceiver1.java
deleted file mode 100644
index 11967f925..000000000
--- a/logback-examples/src/main/java/chapters/appenders/socket/ServerSocketReceiver1.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package chapters.appenders.socket;
-
-import org.slf4j.LoggerFactory;
-
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.joran.JoranConfigurator;
-
-
-/**
- * This application uses a SocketAppender that log messages to a
- * server on a host and port specified by the user. It waits for the
- * user to type a message which will be sent to the server.
- * */
-public class ServerSocketReceiver1 {
-
- static void usage(String msg) {
- System.err.println(msg);
- System.err.println("Usage: java " + ServerSocketReceiver1.class.getName() +
- " configFile\n" +
- " configFile a logback configuration file" +
- " in XML format.");
- System.exit(1);
- }
-
- static public void main(String[] args) throws Exception {
- if (args.length != 1) {
- usage("Wrong number of arguments.");
- }
-
- String configFile = args[0];
-
- if (configFile.endsWith(".xml")) {
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- JoranConfigurator configurator = new JoranConfigurator();
- lc.stop();
- configurator.setContext(lc);
- configurator.doConfigure(configFile);
- }
-
- Thread.sleep(Long.MAX_VALUE);
- }
-}
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/client.xml b/logback-examples/src/main/java/chapters/appenders/socket/ssl/client.xml
index abd082d4b..616da90ab 100644
--- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/client.xml
+++ b/logback-examples/src/main/java/chapters/appenders/socket/ssl/client.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/client2.xml b/logback-examples/src/main/java/chapters/appenders/socket/ssl/client2.xml
deleted file mode 100644
index 50edf2a79..000000000
--- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/client2.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- %date %-5level [%thread] %logger - %message%n
-
-
-
-
-
-
-
-
- ${host}
- ${port}
- 10000
-
-
- ${truststore}
- ${password}
-
-
-
-
-
-
-
-
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server1.xml b/logback-examples/src/main/java/chapters/appenders/socket/ssl/server.xml
similarity index 96%
rename from logback-examples/src/main/java/chapters/appenders/socket/ssl/server1.xml
rename to logback-examples/src/main/java/chapters/appenders/socket/ssl/server.xml
index 32eb96f60..21abbbd0f 100644
--- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server1.xml
+++ b/logback-examples/src/main/java/chapters/appenders/socket/ssl/server.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml b/logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml
deleted file mode 100644
index 62e5edc69..000000000
--- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server2.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
-
-
-
-
-
-
-
-
- ${port}
-
-
- ${keystore}
- ${password}
-
-
-
-
-
-
-
-
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server3.xml b/logback-examples/src/main/java/chapters/appenders/socket/ssl/server3.xml
deleted file mode 100644
index 4b90daefc..000000000
--- a/logback-examples/src/main/java/chapters/appenders/socket/ssl/server3.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
- ${port}
- ${includeCallerData}
-
-
- ${keystore}
- ${password}
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/ServerSocketAppender1.java b/logback-examples/src/main/java/chapters/receivers/socket/AppenderExample.java
similarity index 100%
rename from logback-examples/src/main/java/chapters/appenders/socket/ServerSocketAppender1.java
rename to logback-examples/src/main/java/chapters/receivers/socket/AppenderExample.java
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/SocketReceiver1.java b/logback-examples/src/main/java/chapters/receivers/socket/ReceiverExample.java
similarity index 100%
rename from logback-examples/src/main/java/chapters/appenders/socket/SocketReceiver1.java
rename to logback-examples/src/main/java/chapters/receivers/socket/ReceiverExample.java
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/server4.xml b/logback-examples/src/main/java/chapters/receivers/socket/appender1.xml
similarity index 100%
rename from logback-examples/src/main/java/chapters/appenders/socket/server4.xml
rename to logback-examples/src/main/java/chapters/receivers/socket/appender1.xml
diff --git a/logback-examples/src/main/java/chapters/appenders/socket/server3.xml b/logback-examples/src/main/java/chapters/receivers/socket/receiver1.xml
similarity index 100%
rename from logback-examples/src/main/java/chapters/appenders/socket/server3.xml
rename to logback-examples/src/main/java/chapters/receivers/socket/receiver1.xml
--
GitLab
From 34ad187dd5e9e54ca1be51ad69f3b80404cfbfc2 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Sun, 14 Apr 2013 08:10:26 -0400
Subject: [PATCH 029/260] examples of receiver usage
These were previously in the appenders chapter, now moved to the
receivers chapter, and refined a bit to make them a bit easier to
follow.
---
.../receivers/socket/AppenderExample.java | 14 ++++----
.../receivers/socket/ReceiverExample.java | 11 +++---
.../chapters/receivers/socket/appender1.xml | 8 ++---
.../chapters/receivers/socket/appender2.xml | 28 +++++++++++++++
.../chapters/receivers/socket/appender3.xml | 21 ++++++++++++
.../chapters/receivers/socket/appender4.xml | 27 +++++++++++++++
.../chapters/receivers/socket/receiver2.xml | 32 +++++++++++++++++
.../chapters/receivers/socket/receiver3.xml | 28 +++++++++++++++
.../chapters/receivers/socket/receiver4.xml | 34 +++++++++++++++++++
9 files changed, 186 insertions(+), 17 deletions(-)
create mode 100644 logback-examples/src/main/java/chapters/receivers/socket/appender2.xml
create mode 100644 logback-examples/src/main/java/chapters/receivers/socket/appender3.xml
create mode 100644 logback-examples/src/main/java/chapters/receivers/socket/appender4.xml
create mode 100644 logback-examples/src/main/java/chapters/receivers/socket/receiver2.xml
create mode 100644 logback-examples/src/main/java/chapters/receivers/socket/receiver3.xml
create mode 100644 logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/AppenderExample.java b/logback-examples/src/main/java/chapters/receivers/socket/AppenderExample.java
index 8ecff7fec..62f0c42e1 100644
--- a/logback-examples/src/main/java/chapters/receivers/socket/AppenderExample.java
+++ b/logback-examples/src/main/java/chapters/receivers/socket/AppenderExample.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package chapters.appenders.socket;
+package chapters.receivers.socket;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -28,15 +28,15 @@ import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
/**
- * This application loads a configuration containing a
- * {@link ServerSocketAppender} and then allows the user to enter messages
- * which will be relayed to remote clients via this appender.
+ * This application loads a configuration containing some form of
+ * socket appender and then allows the user to enter messages
+ * which will be relayed to remote clients via the appender.
*/
-public class ServerSocketAppender1 {
+public class AppenderExample {
static void usage(String msg) {
System.err.println(msg);
- System.err.println("Usage: java " + ServerSocketAppender1.class.getName() +
+ System.err.println("Usage: java " + AppenderExample.class.getName() +
" configFile\n" +
" configFile a logback configuration file" +
" in XML format.");
@@ -58,7 +58,7 @@ public class ServerSocketAppender1 {
configurator.doConfigure(configFile);
}
- Logger logger = LoggerFactory.getLogger(ServerSocketAppender1.class);
+ Logger logger = LoggerFactory.getLogger(AppenderExample.class);
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/ReceiverExample.java b/logback-examples/src/main/java/chapters/receivers/socket/ReceiverExample.java
index c7e2db7e7..ab2aae8b7 100644
--- a/logback-examples/src/main/java/chapters/receivers/socket/ReceiverExample.java
+++ b/logback-examples/src/main/java/chapters/receivers/socket/ReceiverExample.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package chapters.appenders.socket;
+package chapters.receivers.socket;
import org.slf4j.LoggerFactory;
@@ -25,14 +25,14 @@ import ch.qos.logback.classic.joran.JoranConfigurator;
/**
* This application loads a configuration containing a
- * {@link SocketRemote} and then logs events received from the remote
- * appender to the console.
+ * receiver component and logs events received from the remote
+ * appender according to the local configuration.
*/
-public class SocketReceiver1 {
+public class ReceiverExample {
static void usage(String msg) {
System.err.println(msg);
- System.err.println("Usage: java " + SocketReceiver1.class.getName() +
+ System.err.println("Usage: java " + ReceiverExample.class.getName() +
" configFile\n" +
" configFile a logback configuration file" +
" in XML format.");
@@ -55,7 +55,6 @@ public class SocketReceiver1 {
}
Thread.sleep(Long.MAX_VALUE);
- ((LoggerContext) LoggerFactory.getILoggerFactory()).stop();
}
}
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/appender1.xml b/logback-examples/src/main/java/chapters/receivers/socket/appender1.xml
index acceeb301..f50b2ad01 100644
--- a/logback-examples/src/main/java/chapters/receivers/socket/appender1.xml
+++ b/logback-examples/src/main/java/chapters/receivers/socket/appender1.xml
@@ -1,15 +1,15 @@
-
+
-
+
+ ${host}${port}
- ${includeCallerData}
+ 10000
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/appender2.xml b/logback-examples/src/main/java/chapters/receivers/socket/appender2.xml
new file mode 100644
index 000000000..d938cad5e
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/receivers/socket/appender2.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+ ${host}
+ ${port}
+ 10000
+
+
+ ${truststore}
+ ${password}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/appender3.xml b/logback-examples/src/main/java/chapters/receivers/socket/appender3.xml
new file mode 100644
index 000000000..4ab2c5d6b
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/receivers/socket/appender3.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+ ${port}
+
+
+
+
+
+
+
+
+
+
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/appender4.xml b/logback-examples/src/main/java/chapters/receivers/socket/appender4.xml
new file mode 100644
index 000000000..12a8599d6
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/receivers/socket/appender4.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+ ${port}
+
+
+ ${keystore}
+ ${password}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/receiver2.xml b/logback-examples/src/main/java/chapters/receivers/socket/receiver2.xml
new file mode 100644
index 000000000..87575267c
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/receivers/socket/receiver2.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
+
+
+
+
+
+
+
+
+ ${port}
+
+
+ ${keystore}
+ ${password}
+
+
+
+
+
+
+
+
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/receiver3.xml b/logback-examples/src/main/java/chapters/receivers/socket/receiver3.xml
new file mode 100644
index 000000000..64b4f8092
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/receivers/socket/receiver3.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
+
+
+
+
+
+
+
+
+ ${host}
+ ${port}
+ 10000
+
+
+
+
+
+
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml b/logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml
new file mode 100644
index 000000000..c0f51ad87
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
+
+
+
+
+
+
+
+
+ ${host}
+ ${port}
+ 10000
+
+
+ ${truststore}
+ ${password}
+
+
+
+
+
+
+
+
--
GitLab
From 3e41c8baa5e28230814e6eba021761e73f6c1884 Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Sun, 14 Apr 2013 08:12:03 -0400
Subject: [PATCH 030/260] work in progress on Using SSL chapter of the manual
Added some language to define "server component" and "client component",
fixed some overall formatting problems, lots of minor fixes and improvements,
added examples of using JSSE system properties, added standard footer.
---
.../src/site/pages/manual/usingSSL.html | 183 ++++++++++++++----
1 file changed, 140 insertions(+), 43 deletions(-)
diff --git a/logback-site/src/site/pages/manual/usingSSL.html b/logback-site/src/site/pages/manual/usingSSL.html
index 42ae0f897..9c089cedc 100644
--- a/logback-site/src/site/pages/manual/usingSSL.html
+++ b/logback-site/src/site/pages/manual/usingSSL.html
@@ -36,9 +36,8 @@
-
-
-
+
+
Logback supports the use of the Secure Sockets Layer
(SSL) when delivering log events from a socket-based appender
@@ -47,12 +46,59 @@
over a secure channel.
+
SSL and Component Roles
+
+
Logback components such as appenders and receivers may act in
+ either the server role or the client role, with respect to network
+ connection initiation. When acting in the server role, a logback
+ component passively listens for connections from remote client
+ components. Conversely, a component acting in the client role
+ initiates a connection to remote server component. For example,
+ an appender acting in the client role connects to a
+ receiver acting in the server role. Or a receiver
+ acting in the client role connects to an appender
+ acting in the server role.
+
+
The roles of the components are generally determined by the
+ component type. For example, an SSLServerSocketAppender
+ is an appender component that acts in the server role, while an
+ SSLSocketAppender is an appender component that acts
+ in the client role. Thus the developer or application administrator
+ can configure Logback components to support the desired direction
+ of network connection initiation.
+
+
The direction of connection initiation is significant in the
+ context of SSL, because in SSL a server component must possess an
+ X.509 credential to identify itself to connecting clients. A
+ client component, when connecting to the server, uses the server's
+ certificate to validate that the server is trusted. The
+ developer or application administrator must be aware of the
+ roles of Logback components, so as to properly configure the
+ server's key store (containing the server's X.509 credential)
+ and the client's trust store (containing self-signed
+ root certificates used when validating server trust).
+
+
When SSL is configured for mutual authentication, then
+ both the server component and the client component must possess
+ valid X.509 credentials whose trust can be asserted by their
+ respective peer. Mutual authentication is configured in the
+ server component, therefore the developer or application
+ administrator must be aware of which components are acting in
+ the server role.
+
+
In this chapter, we use the term server component
+ or simply server to refer to a Logback component such
+ as an appender or receiver that is acting in the server role. We
+ use the term client component or simply client
+ to refer to a component that is acting in the client role.
+
SSL and X.509 Certificates
+
In order to use SSL-enabled Logback components, you will need an
X.509 credential (a private key, corresponding certificate,
- and CA certification chain) to identify your Logback components
+ and CA certification chain) to identify your components
that act as SSL servers. If you wish to use mutual authentication,
- you will also need credentials for your Logback components that
+ you will also need credentials for your components that
act as SSL clients.
While you can use a credential issued by a commercial
@@ -61,12 +107,12 @@
following is all that is required:
-
The component acting in the server role must be configured
+
The server component must be configured
with a key store containing the server's private key,
corresponding certificate, and CA certification chain
(if not using a self-signed certificate).
-
The component acting in the client role must be configured
+
The client component must be configured
with a trust store containing trusted root CA
certificate(s) or the server's self-signed root certificate.
@@ -86,8 +132,8 @@
Basic SSL Configuration using JSSE System Properties
Fortunately, nearly all of the configurable SSL properties for
SSL-enabled Logback components have reasonable defaults. In
- most cases all that is needed to use SSL-enabled Logback
- components is the configuration of some JSSE system properties.
+ most cases all that is needed is the configuration of some JSSE
+ system properties.
The remainder of this section describes the specific JSSE
@@ -98,9 +144,10 @@
system properties to customize JSSE.
-
If you're using any of logback's SSL-enabled appender or receiver
+
If you're using any of Logback's SSL-enabled appender or receiver
components that act in the server role (e.g.
- SSLServerSocketReceiver, ServerSocketAppender,
+ SSLServerSocketReceiver,
+ SSLServerSocketAppender,
or SimpleSSLSocketServer) you'll need to configure
JSSE system properties that provide the location, type, and
password of the key store containing a private key and
@@ -133,21 +180,22 @@
See Examples below for examples of
- setting these system properties when starting a server
- application via a command-line interface.
+ setting these system properties when starting an application
+ that uses Logback's SSL-enabled server components.
-
If your logback server component is using a certificate
- that was signed by a commercial certification authority (CA), you
- probably don't need to provide any SSL configuration
- in your applications that SSL-enabled client components.
- When using a commercially-signed certificate for your server
- component, simply setting the system key store properties for JVM
- that runs the server component is usually all that is needed.
+
If your server component is using a certificate
+ that was signed by a commercial certification authority (CA),
+ you probably don't need to provide any SSL
+ configuration in your applications that use SSL-enabled client
+ components. When using a commercially-signed
+ certificate for your server component, simply setting the
+ system key store properties for JVM that runs the server
+ component is usually all that is needed.
-
If are using either a self-signed logback server certificate
- or your logback server certificate was signed by a
+
If you are using either a self-signed server certificate
+ or your server certificate was signed by a
certification authority (CA) that is not among those whose root
certificates are in the Java platform's default trust store
(e.g. when your organization has its own internal certification
@@ -155,9 +203,9 @@
properties that provide the location, type, and password of the
trust store containing your server's certificate or trusted
root certificates for the certification authority (CA) that
- signed your server's certificate. These properties will
- need to be set in the application that utilizes
- SSLSocketAppender.
+ signed your server's certificate. These properties will
+ need to be set in each application that utilizes an SSL-enabled
+ client component.
@@ -170,7 +218,7 @@
javax.net.ssl.trustStore
Specifies a filesystem path to the file containing your
- logback server component's certificate or trusted root
+ server component's certificate or trusted root
certificate(s) for the certification authority (CA) that
signed the server certificate.
@@ -188,8 +236,8 @@
See Examples below for examples of
- setting these system properties when starting a client
- application via a command-line interface.
+ setting these system properties when starting an application
+ that utilizes Logback's SSL-enabled client components.
This configuration specifies the location of the key store
@@ -248,7 +297,7 @@
the key store.
If you wanted to use SSLSocketAppender in your
- application's logback configuration, but did not want to change
+ application's Logback configuration, but did not want to change
the application's default trust store using the JSSE
javax.net.ssl.trustStore property, you could
configure the appender as follows.
@@ -260,6 +309,7 @@
<ssl>
<trustStore>
<location>classpath:/logging-server-truststore.jks</location>
+ <password>changeit</password>
</trustStore>
</ssl>
</appender>
@@ -293,7 +343,7 @@
When configuring SSL for your components
you need only configure those SSL properties for which the
defaults are not adequate. Overspecifying the SSL configuration
- is often those cause of difficult-to-diagnose problems.
+ is often the cause of difficult-to-diagnose problems.
The following table describes the top-level SSL configuration
@@ -742,8 +792,53 @@
-
Examples
+
Examples
+
+
Using JSSE System Properties
+
JSSE system properties can be used to specify the location and
+ password for a key store containing your server's X.509 credential,
+ or to specify the location and password for a trust store
+ containing self-signed root CA certificates used by your client
+ components to validate server trust.
+
+
Specifying the Server's Key Store
+
When running a server component, you need to specify the location
+ and password for the key store containing the server's credential.
+ One way to do this is using JSSE system properties. The following
+ example shows a command line that could be used to start the
+ SimpleSSLSocketServer that is shipped with Logback.
Note that when using the JSSE keyStore system property,
+ a path to the key store is specified. When specifying the location
+ in logback.xml, a URL for the key store is specified.
+
+
While this example starts the standalone server application
+ provided with Logback, the same system properties could be specified
+ to start any application that uses an SSL-enabled Logback server
+ component.
+
+
Specifying the Client's Trust Store
+
+
When using a client component, you need to specify the location
+ and password for a trust store containing root CA certificates used
+ for validating server trust. One way to do this is using JSSE
+ system properties. The following example shows a command line
+ that could be used to start an application named
+ com.example.MyLoggingApplication that uses one or
+ more of Logback's SSL-enabled client components.
Note that when using the JSSE trustStore system property,
+ a path to the key store is specified. When specifying the location
+ in logback.xml, a URL for the trust store is specified.
+
Creating and Using a Self-Signed Server Component Credential
To generate a self-signed certificate, you can use the keytool
utility that is shipped with the Java Runtime Environment (JRE).
@@ -902,10 +997,10 @@ Trust this certificate? [no]: <Enter "yes">
In settings where secure communications are required, it is often
necessary to audit the configuration of components that use SSL to
validate conformance with local security policies. The SSL
- support in Logback Classic addresses this need by providing detailed
- logging of SSL configuration when the logback configuration is
- initialized. You can enable audit logging using the
- debug property in the configuration:
+ support in Logback addresses this need by providing detailed
+ logging of SSL configuration when Logback is initialized. You can
+ enable audit logging using the debug property in the
+ configuration:
<configuration debug="true">
@@ -1192,6 +1287,8 @@ Trust this certificate? [no]: <Enter "yes">
properties on both the server and client.
+
+
\ No newline at end of file
--
GitLab
From 18d44a8fa20987c5dbeae6be2eadf3b5b9c74a2b Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Sun, 14 Apr 2013 08:16:16 -0400
Subject: [PATCH 031/260] fixed location of server config for SSL example
---
logback-site/src/site/pages/manual/appenders.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index 4260654eb..17e6e9abc 100755
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -1825,7 +1825,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
');
--
GitLab
From 9c6e7aa343552bfc14c3427d1f5a93330219b7df Mon Sep 17 00:00:00 2001
From: Carl Harris
Date: Sun, 14 Apr 2013 08:22:12 -0400
Subject: [PATCH 033/260] pared down and refined news items for receivers and
SSL appenders
Now the focus is on just describing the highlights and deferring
the details to the appropriate chapters of the manual.
---
logback-site/src/site/pages/news.html | 75 +++++++++++----------------
1 file changed, 31 insertions(+), 44 deletions(-)
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index e7e487605..85f6a8fb2 100755
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -32,52 +32,39 @@
April, 2013 - Release of version 1.0.12
-
Several improvements and additions to socket-based appenders are
- included in this release:
-
-
-
A new SSLSocketAppender extends the basic
- SocketAppender providing the ability to deliver logging
- events over the Secure Socket Layer (SSL). The corresponding
- SimpleSSLSocketServer extends the basic
- SimpleSocketServer as a basic logging server application
- that receives logging events from a SSLSocketAppender.
-
+
A new SSLSocketAppender extends the basic
+ SocketAppender providing the ability to deliver
+ logging events over the Secure Socket Layer (SSL). The
+ corresponding SimpleSSLSocketServer extends the classic
+ SimpleSocketServer as a basic logging server
+ application that receives logging events from a
+ SSLSocketAppender.
-
A new SocketServer component (and its SSL-enabled
- counterpart, SSLSocketServer) provides the ability to
- incorporate logging server functionality into any application
- that uses Logback Classic, as an alternative to the simple standalone
- socket server application provided with logback. The new server
- component is configured in logback.xml in the same manner as
- other logback components such as appenders and loggers. A logback
- configuration that includes a server component listens passively on
- a TCP socket for connections from incoming socket appender clients.
- Logging events received from remote appenders are logged according to
- the local configuration. See
- SocketServer and SSLSocketServer in the manual for usage
- instructions.
-
+
While SimpleSocketServer (and its new SSL-enabled
+ counterpart, SimpleSSLSocketServer) provide an
+ easy-to-use standalone logging server application, a new component
+ type known as a receiver allows any application
+ to receive logging events from remote appenders over a TCP/IP network
+ connection, using Logback Classic. Receiver components are
+ configured in logback.xml just like any other logback
+ component.
-
While SocketAppender is designed to initiate a connection
- to a remote logging server in order to deliver logging events, a new
- ServerSocketAppender reverses the direction of connection
- initiation. A logback configuration that utilizes
- ServerSocketAppender (or SSLServerSocketAppender)
- listens passively on a TCP socket for connections from interested
- clients that wish to receive logging events. The corresponding
- SocketRemote (and SSLSocketRemote) provides
- a component that can be added to any logback configuration in order to
- connect to a remote server socket appender, and to log events received
- from the remote appender according to local configuration. See
- ServerSocketAppender
- and SSLServerSocketAppender in the manual for usage instructions.
-
-
-
-
All of the new capabilities for socket-based appenders were
- contributed by Carl Harris.
-
+
A receiver can either listen passively for connections from
+ remote SocketAppender components acting as clients,
+ or it can assume the client role, initiating a connection to a
+ remote appender acting as a server. The receiver components
+ shipped with Logback include full support for logging event
+ delivery over the Secure Sockets Layer (SSL).
+
+
All of the new socket-based receiver and appender components were
+ contributed by Carl Harris. See
+ Receivers in the
+ Logback Manual for more information on
+ configuring receiver components. See
+ SocketAppender and
+ SocketServerAppender
+ for information on configuring appenders as event sources for
+ receiver components.
RollingFileAppender will now detect when file property collides with
Date: Sun, 14 Apr 2013 08:29:09 -0400
Subject: [PATCH 034/260] corrections to comments in example configs for
receiver components
---
.../src/main/java/chapters/receivers/socket/appender2.xml | 2 +-
.../src/main/java/chapters/receivers/socket/appender4.xml | 2 +-
.../src/main/java/chapters/receivers/socket/receiver4.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/appender2.xml b/logback-examples/src/main/java/chapters/receivers/socket/appender2.xml
index d938cad5e..020eb51a9 100644
--- a/logback-examples/src/main/java/chapters/receivers/socket/appender2.xml
+++ b/logback-examples/src/main/java/chapters/receivers/socket/appender2.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/appender4.xml b/logback-examples/src/main/java/chapters/receivers/socket/appender4.xml
index 12a8599d6..5f670b185 100644
--- a/logback-examples/src/main/java/chapters/receivers/socket/appender4.xml
+++ b/logback-examples/src/main/java/chapters/receivers/socket/appender4.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml b/logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml
index c0f51ad87..f435cff63 100644
--- a/logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml
+++ b/logback-examples/src/main/java/chapters/receivers/socket/receiver4.xml
@@ -1,7 +1,7 @@
-
+
--
GitLab
From 0eef53bb92deb3569f21d4ac2eab492c9a4f217d Mon Sep 17 00:00:00 2001
From: Ceki Gulcu
Date: Sun, 14 Apr 2013 21:03:44 +0200
Subject: [PATCH 035/260] added link to
http://nurkiewicz.blogspot.ch/2013/04/siftingappender-logging-different.html
---
logback-site/src/site/pages/documentation.html | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/logback-site/src/site/pages/documentation.html b/logback-site/src/site/pages/documentation.html
index 72cee6995..2b521f66e 100644
--- a/logback-site/src/site/pages/documentation.html
+++ b/logback-site/src/site/pages/documentation.html
@@ -87,6 +87,14 @@
Enterprise Spring Best Practices - Part 1 - Project Config
by Gordon Dickens
+
+
Traditionally, a SocketAppender has acted as a
- client, connecting to a standalone SimpleSocketServer
- application acting as a server. The receiver component offers much
+
Historically, support for logging event delivery over a network
+ connection in Logback has been provided by SocketAppender
+ and the corresponding SimpleSocketServer. The appender
+ acts as a client, initiating a network connection to the server
+ application, and delivering logging events via the network connection.
+ The receiver component and corresponding appender support offers much
greater flexibility.
A receiver component is configured in logback.xml, just
@@ -79,8 +82,8 @@
appender and receiver, logging events always flow from
the appender towards the receiver.
-
This flexibility to allow a receiver to initiate the connection
- to a logback appender is particularly useful in certain situations:
+
The flexibility to allow a receiver to initiate the connection
+ to an appender is particularly useful in certain situations:
For security reasons, a central logging server may be
@@ -94,14 +97,15 @@
and enterprise management applications to have access to the
logging event stream of running applications. Traditionally,
Logback has supported this (for example in Logback Beagle) by
- requiring the receiving application to act in the server role,
- passively listening for connections a remote appender. This
- can prove difficult to manage, especially for tools running on
- a developer's workstation, which may indeed by mobile. However,
- such tools can now be implemented using a Logback receiver
- component acting in the client role, initiating a connection to
- a remote appender in order to receive logging events for local
- display, filtering, and alerting.
+ requiring the recipient application (e.g. a developer tool running
+ in an IDE) to act in the server role, passively listening for
+ connections from a remote appender. This can prove difficult to
+ manage, especially for tools running on a developer's workstation,
+ which may indeed by mobile. However, such tools can now be
+ implemented using a Logback receiver component acting in the
+ client role, initiating a connection to a remote appender in
+ order to receive logging events for local display, filtering,
+ and alerting.
@@ -116,12 +120,11 @@
A receiver that is configured to act in the server role passively
listens for incoming connections from remote appenders. This is
- functionally equivalent to the traditional
+ functionally equivalent to using the standalone
SimpleSocketServer application, except that by using
the receiver component, any application that uses Logback
Classic can receive logging events from remote appenders by simply
- configuring the receiver in logback.xml like any other
- logback component.
This property specifies configuration for a thread pool that will
- be used to manage the appender's thread resources. In most cases,
+ be used to manage the receiver's thread resources. In most cases,
this configuration is not required, as the defaults are generally
adequate. See ThreadPoolFactoryBean for a description of the
@@ -220,6 +223,7 @@
From a shell in the logback-examples directory,
we can run our example server application as follows:
Note that the keystore property given on the command
line specifies a file URL that identifies the location of the key
@@ -295,24 +299,25 @@
Using SSL.
-
Also we must point out that our example X.509
- credential is suitable for testing and experimentation, only.
- In a production setting, you should obtain an appropriate
- X.509 credential to identify your SSL-enabled logback components.
- See Using SSL for more information.
-
We can connect to the running receiver using a client application
- that is configured with a SSLSocketAppender. Our example
- client application simply loads a logback configuration that will
- connect a socket appender to our example receiver. It then awaits
- input from the user in the form of a message that will be relayed to
- the receiver. We can run the example client application as follows:
+ that is configured with a SSLSocketAppender. We use
+ the sample example client application used in the previous example,
+ with a configuration file that uses an SSL-enabled appender. We
+ run the example as follows:
Note that our example is using a self-signed X.509 credential that
+ is suitable for testing and experimentation, only. In a
+ production setting, you should obtain an appropriate X.509 credential
+ to identify your SSL-enabled logback components. See
+ Using SSL for more information.
+
Receivers that Act in the Client Role
@@ -400,7 +405,7 @@
</configuration>
-
This configuration will cause logback to connect to an
+
This configuration will cause logback to connect to a
ServerSocketAppender running on the host and port specified
by the host and port substitution variables. Logging
events received from the remote appender will be logged locally
@@ -417,9 +422,9 @@
The example loads the configuration and then simply waits for logging
events from the remote appender. If you run this example when the remote
appender is not running, you'll see connection refused messages
- appearing in the log output, periodically. The SocketReceiver
- component will periodically attempt to reconnect to the remote appender
- until it succeeds or until the logger context is shut down. The delay
+ appearing in the log output, periodically. The receiver will
+ periodically attempt to reconnect to the remote appender until it
+ succeeds or until the logger context is shut down. The delay
interval between attempts is configurable using the
reconnectionDelay property as shown in the
example configuration.
If you enter a message to send when the receiver is not connected,
+ note that the message is simply discarded.
Using SocketSSLReceiver
-
- The configuration needed the SSLSocketReceiver is very
- similar to that used with SocketReceiver. The essential
- differences are in the class specified for the receiver and the ability
- to nest the ssl property to specify SSL
- configuration properties. The following example illustrates a basic
- configuration:
-
+
The configuration needed for SSLSocketReceiver is very
+ similar to that used with SocketReceiver. The essential
+ differences are in the class specified for the receiver and the ability
+ to nest the ssl property to specify SSL
+ configuration properties. The following example illustrates a basic
+ configuration:
+
@@ -487,17 +493,10 @@
on configuring SSL properties.
-
It is important to note once again, that our example is using a
- self-signed X.509 credential that suitable for testing and
- experimentation, only. In a production setting, you should
- obtain an appropriate X.509 credential to identify your SSL-enabled
- logback components. See Using SSL
- for more information.
-
You can run this example configuration using the following command:
If you enter a message to send when the receiver is not connected,
+ note that the message is simply discarded.
+
+
It is important to note once again that our example is using a
+ self-signed X.509 credential that is suitable for testing and
+ experimentation, only. In a production setting, you should
+ obtain an appropriate X.509 credential to identify your SSL-enabled
+ logback components. See Using SSL
+ for more information.