You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2017/04/10 14:11:33 UTC
[01/14] logging-log4j2 git commit: Move server components from core
to new server module
Repository: logging-log4j2
Updated Branches:
refs/heads/master 1475bd988 -> fea17ad6b
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/package-info.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/package-info.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/package-info.java
new file mode 100644
index 0000000..0d9d027
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+/**
+ * Standalone server classes for consuming log events over a network. Each of the various servers should be used with
+ * another Log4j configuration to handle incoming {@link org.apache.logging.log4j.core.LogEvent}s. It is recommended
+ * to consider using the <a href="../../../../../../../../../manual/appenders.html#FlumeAppender">Flume Appender</a>
+ * for highly reliable networked logging.
+ */
+package org.apache.logging.log4j.core.net.server;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/site/markdown/index.md
----------------------------------------------------------------------
diff --git a/log4j-server/src/site/markdown/index.md b/log4j-server/src/site/markdown/index.md
new file mode 100644
index 0000000..b66e935
--- /dev/null
+++ b/log4j-server/src/site/markdown/index.md
@@ -0,0 +1,29 @@
+<!-- vim: set syn=markdown : -->
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+# Log4j Server components
+
+## Log4j Server components
+
+
+## Requirements
+
+The Log4j Server components requires the Log4j 2 API and core. This component was introduced in Log4j 2.8.2,
+before it was part of log4j-core. For more information, see [Runtime Dependencies](../runtime-dependencies.html).
+
+## Usage
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/site/site.xml
----------------------------------------------------------------------
diff --git a/log4j-server/src/site/site.xml b/log4j-server/src/site/site.xml
new file mode 100644
index 0000000..f863dbf
--- /dev/null
+++ b/log4j-server/src/site/site.xml
@@ -0,0 +1,52 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project name="Log4j IOStreams"
+ xmlns="http://maven.apache.org/DECORATION/1.4.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.4.0 http://maven.apache.org/xsd/decoration-1.4.0.xsd">
+ <body>
+ <links>
+ <item name="Apache" href="http://www.apache.org/" />
+ <item name="Logging Services" href="http://logging.apache.org/"/>
+ <item name="Log4j" href="../index.html"/>
+ </links>
+
+ <!-- Component-specific reports -->
+ <menu ref="reports"/>
+
+ <!-- Overall Project Info -->
+ <menu name="Log4j Project Information" img="icon-info-sign">
+ <item name="Dependencies" href="../dependencies.html" />
+ <item name="Dependency Convergence" href="../dependency-convergence.html" />
+ <item name="Dependency Management" href="../dependency-management.html" />
+ <item name="Project Team" href="../team-list.html" />
+ <item name="Mailing Lists" href="../mail-lists.html" />
+ <item name="Issue Tracking" href="../issue-tracking.html" />
+ <item name="Project License" href="../license.html" />
+ <item name="Source Repository" href="../source-repository.html" />
+ <item name="Project Summary" href="../project-summary.html" />
+ </menu>
+
+ <menu name="Log4j Project Reports" img="icon-cog">
+ <item name="Changes Report" href="../changes-report.html" />
+ <item name="JIRA Report" href="../jira-report.html" />
+ <item name="Surefire Report" href="../surefire-report.html" />
+ <item name="RAT Report" href="../rat-report.html" />
+ </menu>
+ </body>
+</project>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/AbstractSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/AbstractSocketServerTest.java b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/AbstractSocketServerTest.java
new file mode 100644
index 0000000..7351313
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/AbstractSocketServerTest.java
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.AppenderLoggingException;
+import org.apache.logging.log4j.core.appender.ConsoleAppender;
+import org.apache.logging.log4j.core.appender.SocketAppender;
+import org.apache.logging.log4j.core.layout.JsonLayout;
+import org.apache.logging.log4j.core.layout.PatternLayout;
+import org.apache.logging.log4j.core.layout.XmlLayout;
+import org.apache.logging.log4j.core.net.Protocol;
+import org.apache.logging.log4j.test.AvailablePortFinder;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.After;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public abstract class AbstractSocketServerTest {
+
+ protected static Thread thread;
+
+ private static final String MESSAGE = "This is test message";
+
+ private static final String MESSAGE_2 = "This is test message 2";
+
+ private static final String MESSAGE_WITH_SPECIAL_CHARS = "{This}\n[is]\"n\"a\"\r\ntrue:\n\ttest,\nmessage";
+
+ static final int PORT_NUM = AvailablePortFinder.getNextAvailable();
+
+ static final int PORT = PORT_NUM;
+
+ private final LoggerContext ctx = LoggerContext.getContext(false);
+
+ private final boolean expectLengthException;
+
+ protected final int port;
+
+ protected final Protocol protocol;
+
+ private final Logger rootLogger = ctx.getLogger(AbstractSocketServerTest.class.getSimpleName());
+
+ protected AbstractSocketServerTest(final Protocol protocol, final int port, final boolean expectLengthException) {
+ this.protocol = protocol;
+ this.port = port;
+ this.expectLengthException = expectLengthException;
+ }
+
+ protected Layout<String> createJsonLayout() {
+ // @formatter: off
+ return JsonLayout.newBuilder()
+ .setLocationInfo(true)
+ .setProperties(true)
+ .setPropertiesAsList(false)
+ .setComplete(false)
+ .setCompact(false)
+ .setEventEol(false)
+ .setIncludeStacktrace(true)
+ .build();
+ // @formatter: on
+
+ //return JsonLayout.createLayout(null, true, true, false, false, false, false, null, null, null, true);
+ }
+
+ protected abstract Layout<? extends Serializable> createLayout();
+
+ protected Layout<? extends Serializable> createSerializedLayout() {
+ return null;
+ }
+
+ protected Layout<String> createXmlLayout() {
+ return XmlLayout.createLayout(true, true, false, false, null, true);
+ }
+
+ @After
+ public void tearDown() {
+ final Map<String, Appender> map = rootLogger.getAppenders();
+ for (final Map.Entry<String, Appender> entry : map.entrySet()) {
+ final Appender appender = entry.getValue();
+ rootLogger.removeAppender(appender);
+ appender.stop();
+ }
+ }
+
+ @Test
+ @Ignore("Broken test?")
+ public void test1000ShortMessages() throws Exception {
+ testServer(1000);
+ }
+
+ @Test
+ @Ignore("Broken test?")
+ public void test100ShortMessages() throws Exception {
+ testServer(100);
+ }
+
+ @Test
+ public void test10ShortMessages() throws Exception {
+ testServer(10);
+ }
+
+ @Test
+ public void test1ShortMessages() throws Exception {
+ testServer(1);
+ }
+
+ @Test
+ public void test2ShortMessages() throws Exception {
+ testServer(2);
+ }
+
+ @Test
+ public void test64KBMessages() throws Exception {
+ final char[] a64K = new char[1024 * 64];
+ Arrays.fill(a64K, 'a');
+ final String m1 = new String(a64K);
+ final String m2 = MESSAGE_2 + m1;
+ if (expectLengthException) {
+ try {
+ testServer(m1, m2);
+ } catch (final AppenderLoggingException are) {
+ assertTrue("", are.getCause() != null && are.getCause() instanceof IOException);
+ // Failure expected.
+ }
+ } else {
+ testServer(m1, m2);
+ }
+ }
+
+
+ @Test
+ public void testMessagesWithSpecialChars() throws Exception {
+ testServer(MESSAGE_WITH_SPECIAL_CHARS);
+ }
+
+
+ private void testServer(final int size) throws Exception {
+ final String[] messages = new String[size];
+ for (int i = 0; i < messages.length; i++) {
+ messages[i] = MESSAGE + " " + i;
+ }
+ testServer(messages);
+ }
+
+ protected void testServer(final String... messages) throws Exception {
+ final Filter socketFilter = new ThreadNameFilter(Filter.Result.NEUTRAL, Filter.Result.DENY);
+ final Filter serverFilter = new ThreadNameFilter(Filter.Result.DENY, Filter.Result.NEUTRAL);
+ final Layout<? extends Serializable> socketLayout = createLayout();
+ final SocketAppender socketAppender = createSocketAppender(socketFilter, socketLayout);
+ socketAppender.start();
+ final ListAppender listAppender = new ListAppender("Events", serverFilter, null, false, false);
+ listAppender.start();
+ final PatternLayout layout = PatternLayout.newBuilder().withPattern("%m %ex%n").build();
+ final ConsoleAppender console = ConsoleAppender.createDefaultAppenderForLayout(layout);
+ final Logger serverLogger = ctx.getLogger(this.getClass().getName());
+ serverLogger.addAppender(console);
+ serverLogger.setAdditive(false);
+
+ // set appender on root and set level to debug
+ rootLogger.addAppender(socketAppender);
+ rootLogger.addAppender(listAppender);
+ rootLogger.setAdditive(false);
+ rootLogger.setLevel(Level.DEBUG);
+ for (final String message : messages) {
+ rootLogger.debug(message);
+ }
+ final int MAX_TRIES = 400;
+ for (int i = 0; i < MAX_TRIES; i++) {
+ if (listAppender.getEvents().size() < messages.length) {
+ try {
+ // Let the server-side read the messages.
+ Thread.sleep(50);
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ break;
+ }
+ }
+ final List<LogEvent> events = listAppender.getEvents();
+ assertNotNull("No event retrieved", events);
+ assertEquals("Incorrect number of events received", messages.length, events.size());
+ for (int i = 0; i < messages.length; i++) {
+ assertTrue("Incorrect event", events.get(i).getMessage().getFormattedMessage().equals(messages[i]));
+ }
+ }
+
+ protected SocketAppender createSocketAppender(final Filter socketFilter,
+ final Layout<? extends Serializable> socketLayout) {
+ // @formatter:off
+ return SocketAppender.newBuilder()
+ .withProtocol(this.protocol)
+ .withHost("localhost")
+ .withPort(this.port)
+ .withReconnectDelayMillis(-1)
+ .withName("test")
+ .withImmediateFlush(true)
+ .withImmediateFail(false)
+ .withIgnoreExceptions(false)
+ .withLayout(socketLayout)
+ .withFilter(socketFilter)
+ .build();
+ // @formatter:on
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/SslXmlSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/SslXmlSocketServerTest.java b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/SslXmlSocketServerTest.java
new file mode 100644
index 0000000..8ca07a4
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/SslXmlSocketServerTest.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.nio.charset.Charset;
+
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.SocketAppender;
+import org.apache.logging.log4j.core.net.Protocol;
+import org.apache.logging.log4j.core.net.ssl.KeyStoreConfiguration;
+import org.apache.logging.log4j.core.net.ssl.SslConfiguration;
+import org.apache.logging.log4j.core.net.ssl.StoreConfigurationException;
+import org.apache.logging.log4j.core.net.ssl.TestConstants;
+import org.apache.logging.log4j.core.net.ssl.TrustStoreConfiguration;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+public class SslXmlSocketServerTest extends AbstractSocketServerTest {
+
+ private static TcpSocketServer<InputStream> server;
+
+ private static SslConfiguration sslConfiguration;
+
+ private static void initServerSocketFactory() throws StoreConfigurationException {
+ final KeyStoreConfiguration ksc = new KeyStoreConfiguration(TestConstants.KEYSTORE_FILE,
+ TestConstants.KEYSTORE_PWD, TestConstants.KEYSTORE_TYPE, null);
+ final TrustStoreConfiguration tsc = new TrustStoreConfiguration(TestConstants.TRUSTSTORE_FILE,
+ TestConstants.TRUSTSTORE_PWD, null, null);
+ sslConfiguration = SslConfiguration.createSSLConfiguration(null, ksc, tsc);
+ }
+
+ @Override
+ protected SocketAppender createSocketAppender(final Filter socketFilter,
+ final Layout<? extends Serializable> socketLayout) {
+ // @formatter:off
+ return SocketAppender.newBuilder()
+ .withProtocol(this.protocol)
+ .withHost("localhost")
+ .withPort(this.port)
+ .withReconnectDelayMillis(-1)
+ .withName("test")
+ .withImmediateFlush(true)
+ .withImmediateFail(false)
+ .withIgnoreExceptions(false)
+ .withLayout(socketLayout)
+ .withFilter(socketFilter)
+ .withSslConfiguration(sslConfiguration)
+ .build();
+ // @formatter:on
+ }
+
+ @BeforeClass
+ public static void setupClass() throws Exception {
+ (LoggerContext.getContext(false)).reconfigure();
+ initServerSocketFactory();
+ // Use a large buffer just to test the code, the UDP test uses a tiny buffer
+ server = new SecureTcpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(1024 * 100,
+ Charset.defaultCharset()), sslConfiguration);
+ thread = server.startNewThread();
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ try {
+ server.shutdown();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ try {
+ thread.join();
+ } catch (final InterruptedException e) {
+ // ignore
+ }
+ }
+
+ public SslXmlSocketServerTest() {
+ super(Protocol.SSL, PORT, false);
+ }
+
+ @Override
+ protected Layout<String> createLayout() {
+ return super.createXmlLayout();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpJsonSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpJsonSocketServerTest.java b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpJsonSocketServerTest.java
new file mode 100644
index 0000000..6420e7e
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpJsonSocketServerTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.net.Protocol;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+public class TcpJsonSocketServerTest extends AbstractSocketServerTest {
+
+ private static TcpSocketServer<InputStream> server;
+
+ @BeforeClass
+ public static void setupClass() throws Exception {
+ (LoggerContext.getContext(false)).reconfigure();
+ server = TcpSocketServer.createJsonSocketServer(PORT_NUM);
+ thread = server.startNewThread();
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ try {
+ server.shutdown();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ try {
+ thread.join();
+ } catch (final InterruptedException e) {
+ // ignore
+ }
+ }
+
+ public TcpJsonSocketServerTest() {
+ super(Protocol.TCP, PORT, false);
+ }
+
+ @Override
+ protected Layout<String> createLayout() {
+ return super.createJsonLayout();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpSerializedSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpSerializedSocketServerTest.java b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpSerializedSocketServerTest.java
new file mode 100644
index 0000000..645701b
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpSerializedSocketServerTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.net.Protocol;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+public class TcpSerializedSocketServerTest extends AbstractSocketServerTest {
+
+ private static TcpSocketServer<ObjectInputStream> server;
+
+ @BeforeClass
+ public static void setupClass() throws Exception {
+ (LoggerContext.getContext(false)).reconfigure();
+ server = TcpSocketServer.createSerializedSocketServer(PORT_NUM);
+ thread = server.startNewThread();
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ try {
+ server.shutdown();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ try {
+ thread.join();
+ } catch (final InterruptedException e) {
+ // ignore
+ }
+ }
+
+ public TcpSerializedSocketServerTest() {
+ super(Protocol.TCP, PORT, false);
+ }
+
+ @Override
+ protected Layout<? extends Serializable> createLayout() {
+ return super.createSerializedLayout();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpXmlSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpXmlSocketServerTest.java b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpXmlSocketServerTest.java
new file mode 100644
index 0000000..2290cbd
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/TcpXmlSocketServerTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.net.Protocol;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+public class TcpXmlSocketServerTest extends AbstractSocketServerTest {
+
+ private static TcpSocketServer<InputStream> server;
+
+ @BeforeClass
+ public static void setupClass() throws Exception {
+ (LoggerContext.getContext(false)).reconfigure();
+ // Use a large buffer just to test the code, the UDP test uses a tiny buffer
+ server = new TcpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(1024 * 100,
+ Charset.defaultCharset()));
+ thread = server.startNewThread();
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ try {
+ server.shutdown();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ try {
+ thread.join();
+ } catch (final InterruptedException e) {
+ // ignore
+ }
+ }
+
+ public TcpXmlSocketServerTest() {
+ super(Protocol.TCP, PORT, false);
+ }
+
+ @Override
+ protected Layout<String> createLayout() {
+ return super.createXmlLayout();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadIdFilter.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadIdFilter.java b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadIdFilter.java
new file mode 100644
index 0000000..49a9595
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadIdFilter.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.net.server;
+
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.filter.AbstractFilter;
+
+/**
+ * TODO Should use thread ID cache?
+ * @since 2.6
+ */
+public class ThreadIdFilter extends AbstractFilter {
+
+ private static final long serialVersionUID = 1L;
+
+ public ThreadIdFilter(final Result onMatch, final Result onMismatch) {
+ super(onMatch, onMismatch);
+ }
+
+ @Override
+ public Filter.Result filter(final LogEvent event) {
+ return event.getThreadId() == Thread.currentThread().getId() ? onMatch : onMismatch;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadNameFilter.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadNameFilter.java b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadNameFilter.java
new file mode 100644
index 0000000..6f6fb13
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadNameFilter.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.net.server;
+
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.filter.AbstractFilter;
+
+/**
+ * TODO Should use thread name cache?
+ */
+public class ThreadNameFilter extends AbstractFilter {
+
+ private static final long serialVersionUID = 1L;
+
+ public ThreadNameFilter(final Result onMatch, final Result onMismatch) {
+ super(onMatch, onMismatch);
+ }
+
+ @Override
+ public Filter.Result filter(final LogEvent event) {
+ return event.getThreadName().equals(Thread.currentThread().getName()) ? onMatch : onMismatch;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadPriorityFilter.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadPriorityFilter.java b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadPriorityFilter.java
new file mode 100644
index 0000000..27ecc7d
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/ThreadPriorityFilter.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.net.server;
+
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.filter.AbstractFilter;
+
+/**
+ * TODO Should use thread priority cache?
+ * @since 2.6
+ */
+public class ThreadPriorityFilter extends AbstractFilter {
+
+ private static final long serialVersionUID = 1L;
+
+ public ThreadPriorityFilter(final Result onMatch, final Result onMismatch) {
+ super(onMatch, onMismatch);
+ }
+
+ @Override
+ public Filter.Result filter(final LogEvent event) {
+ return event.getThreadPriority() == Thread.currentThread().getPriority() ? onMatch : onMismatch;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpJsonSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpJsonSocketServerTest.java b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpJsonSocketServerTest.java
new file mode 100644
index 0000000..3f33b14
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpJsonSocketServerTest.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.InputStream;
+import java.io.Serializable;
+
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.net.Protocol;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+public class UdpJsonSocketServerTest extends AbstractSocketServerTest {
+
+ private static UdpSocketServer<InputStream> server;
+
+ @BeforeClass
+ public static void setupClass() throws Exception {
+ (LoggerContext.getContext(false)).reconfigure();
+ server = UdpSocketServer.createJsonSocketServer(PORT_NUM);
+ thread = server.startNewThread();
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ server.shutdown();
+ try {
+ thread.join();
+ } catch (final InterruptedException e) {
+ // ignore
+ }
+ }
+
+ public UdpJsonSocketServerTest() {
+ super(Protocol.UDP, PORT, true);
+ }
+
+ @Override
+ protected Layout<? extends Serializable> createLayout() {
+ return super.createJsonLayout();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java
new file mode 100644
index 0000000..3e7ecad
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.net.Protocol;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+
+@Ignore
+public class UdpSerializedSocketServerTest extends AbstractSocketServerTest {
+
+ private static UdpSocketServer<ObjectInputStream> server;
+
+ @BeforeClass
+ public static void setupClass() throws Exception {
+ (LoggerContext.getContext(false)).reconfigure();
+ server = UdpSocketServer.createSerializedSocketServer(PORT_NUM);
+ thread = server.startNewThread();
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ server.shutdown();
+ try {
+ thread.join();
+ } catch (final InterruptedException e) {
+ // ignore
+ }
+ }
+
+ public UdpSerializedSocketServerTest() {
+ super(Protocol.UDP, PORT, true);
+ }
+
+ @Override
+ protected Layout<? extends Serializable> createLayout() {
+ return super.createSerializedLayout();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpXmlSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpXmlSocketServerTest.java b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpXmlSocketServerTest.java
new file mode 100644
index 0000000..fa54766
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/core/net/server/UdpXmlSocketServerTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.nio.charset.Charset;
+
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.net.Protocol;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+public class UdpXmlSocketServerTest extends AbstractSocketServerTest {
+
+ private static UdpSocketServer<InputStream> server;
+
+ @BeforeClass
+ public static void setupClass() throws Exception {
+ (LoggerContext.getContext(false)).reconfigure();
+ // Use a tiny buffer just to test the code, the TCP test uses a large buffer
+ server = new UdpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(100,
+ Charset.defaultCharset()));
+ thread = server.startNewThread();
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ server.shutdown();
+ try {
+ thread.join();
+ } catch (final InterruptedException e) {
+ // ignore
+ }
+ }
+
+ public UdpXmlSocketServerTest() {
+ super(Protocol.UDP, PORT, true);
+ }
+
+ @Override
+ protected Layout<? extends Serializable> createLayout() {
+ return super.createXmlLayout();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index e2ed02f..8f43fa3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -356,6 +356,11 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
<version>${project.version}</version>
</dependency>
@@ -1274,6 +1279,7 @@
<module>log4j-web</module>
<module>log4j-perf</module>
<module>log4j-iostreams</module>
+ <module>log4j-server</module>
<module>log4j-jul</module>
<module>log4j-liquibase</module>
<module>log4j-api-scala_2.10</module>
[10/14] logging-log4j2 git commit: Merge branch 'master' into
LOG4J2-1851
Posted by mi...@apache.org.
Merge branch 'master' into LOG4J2-1851
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/6fd6dfcd
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/6fd6dfcd
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/6fd6dfcd
Branch: refs/heads/master
Commit: 6fd6dfcd7fa772ffa1a4d3c9c783b5b0af7501d9
Parents: 3b89ec7 5aff929
Author: Mikael St�ldal <mi...@magine.com>
Authored: Mon Mar 27 14:50:59 2017 +0200
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Mon Mar 27 14:50:59 2017 +0200
----------------------------------------------------------------------
.../logging/log4j/core/appender/RandomAccessFileAppender.java | 2 +-
pom.xml | 2 +-
src/changes/changes.xml | 6 ++++++
3 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6fd6dfcd/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6fd6dfcd/src/changes/changes.xml
----------------------------------------------------------------------
[07/14] logging-log4j2 git commit: Changelog
Posted by mi...@apache.org.
Changelog
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f822bd8e
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f822bd8e
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f822bd8e
Branch: refs/heads/master
Commit: f822bd8e9fd47bdc47ad7637edc9f878877c0984
Parents: 873e7ef
Author: Mikael St�ldal <mi...@magine.com>
Authored: Fri Mar 17 16:12:49 2017 +0100
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Fri Mar 17 16:12:49 2017 +0100
----------------------------------------------------------------------
src/changes/changes.xml | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f822bd8e/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index bd5d131..961d3fc 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -31,6 +31,9 @@
- "remove" - Removed
-->
<release version="2.8.2" date="2017-MM-DD" description="GA Release 2.8.2">
+ <action issue="LOG4J2-1851" dev="mikes" type="update">
+ Move server components from log4j-core to new log4-server module.
+ </action>
<action issue="LOG4J2-1849" dev="rpopma" type="fix">
Fixed daylight savings time issue with FixedDateFormat.
</action>
[02/14] logging-log4j2 git commit: Move server components from core
to new server module
Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpXmlSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpXmlSocketServerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpXmlSocketServerTest.java
deleted file mode 100644
index 2290cbd..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpXmlSocketServerTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class TcpXmlSocketServerTest extends AbstractSocketServerTest {
-
- private static TcpSocketServer<InputStream> server;
-
- @BeforeClass
- public static void setupClass() throws Exception {
- (LoggerContext.getContext(false)).reconfigure();
- // Use a large buffer just to test the code, the UDP test uses a tiny buffer
- server = new TcpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(1024 * 100,
- Charset.defaultCharset()));
- thread = server.startNewThread();
- }
-
- @AfterClass
- public static void tearDownClass() {
- try {
- server.shutdown();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- try {
- thread.join();
- } catch (final InterruptedException e) {
- // ignore
- }
- }
-
- public TcpXmlSocketServerTest() {
- super(Protocol.TCP, PORT, false);
- }
-
- @Override
- protected Layout<String> createLayout() {
- return super.createXmlLayout();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadIdFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadIdFilter.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadIdFilter.java
deleted file mode 100644
index d00edb2..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadIdFilter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.net.server;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.filter.AbstractFilter;
-
-/**
- * TODO Should use thread ID cache?
- * @since 2.6
- */
-public class ThreadIdFilter extends AbstractFilter {
-
- private static final long serialVersionUID = 1L;
-
- public ThreadIdFilter(final Result onMatch, final Result onMismatch) {
- super(onMatch, onMismatch);
- }
-
- @Override
- public Filter.Result filter(final LogEvent event) {
- return event.getThreadId() == Thread.currentThread().getId() ? onMatch : onMismatch;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadNameFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadNameFilter.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadNameFilter.java
deleted file mode 100644
index e5e176d..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadNameFilter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.net.server;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.filter.AbstractFilter;
-
-/**
- * TODO Should use thread name cache?
- */
-public class ThreadNameFilter extends AbstractFilter {
-
- private static final long serialVersionUID = 1L;
-
- public ThreadNameFilter(final Result onMatch, final Result onMismatch) {
- super(onMatch, onMismatch);
- }
-
- @Override
- public Filter.Result filter(final LogEvent event) {
- return event.getThreadName().equals(Thread.currentThread().getName()) ? onMatch : onMismatch;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadPriorityFilter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadPriorityFilter.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadPriorityFilter.java
deleted file mode 100644
index 7c9c734..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/ThreadPriorityFilter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.net.server;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.filter.AbstractFilter;
-
-/**
- * TODO Should use thread priority cache?
- * @since 2.6
- */
-public class ThreadPriorityFilter extends AbstractFilter {
-
- private static final long serialVersionUID = 1L;
-
- public ThreadPriorityFilter(final Result onMatch, final Result onMismatch) {
- super(onMatch, onMismatch);
- }
-
- @Override
- public Filter.Result filter(final LogEvent event) {
- return event.getThreadPriority() == Thread.currentThread().getPriority() ? onMatch : onMismatch;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpJsonSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpJsonSocketServerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpJsonSocketServerTest.java
deleted file mode 100644
index 3f33b14..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpJsonSocketServerTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.InputStream;
-import java.io.Serializable;
-
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class UdpJsonSocketServerTest extends AbstractSocketServerTest {
-
- private static UdpSocketServer<InputStream> server;
-
- @BeforeClass
- public static void setupClass() throws Exception {
- (LoggerContext.getContext(false)).reconfigure();
- server = UdpSocketServer.createJsonSocketServer(PORT_NUM);
- thread = server.startNewThread();
- }
-
- @AfterClass
- public static void tearDownClass() {
- server.shutdown();
- try {
- thread.join();
- } catch (final InterruptedException e) {
- // ignore
- }
- }
-
- public UdpJsonSocketServerTest() {
- super(Protocol.UDP, PORT, true);
- }
-
- @Override
- protected Layout<? extends Serializable> createLayout() {
- return super.createJsonLayout();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java
deleted file mode 100644
index 3e7ecad..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpSerializedSocketServerTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-
-@Ignore
-public class UdpSerializedSocketServerTest extends AbstractSocketServerTest {
-
- private static UdpSocketServer<ObjectInputStream> server;
-
- @BeforeClass
- public static void setupClass() throws Exception {
- (LoggerContext.getContext(false)).reconfigure();
- server = UdpSocketServer.createSerializedSocketServer(PORT_NUM);
- thread = server.startNewThread();
- }
-
- @AfterClass
- public static void tearDownClass() {
- server.shutdown();
- try {
- thread.join();
- } catch (final InterruptedException e) {
- // ignore
- }
- }
-
- public UdpSerializedSocketServerTest() {
- super(Protocol.UDP, PORT, true);
- }
-
- @Override
- protected Layout<? extends Serializable> createLayout() {
- return super.createSerializedLayout();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpXmlSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpXmlSocketServerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpXmlSocketServerTest.java
deleted file mode 100644
index fa54766..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/UdpXmlSocketServerTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.nio.charset.Charset;
-
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class UdpXmlSocketServerTest extends AbstractSocketServerTest {
-
- private static UdpSocketServer<InputStream> server;
-
- @BeforeClass
- public static void setupClass() throws Exception {
- (LoggerContext.getContext(false)).reconfigure();
- // Use a tiny buffer just to test the code, the TCP test uses a large buffer
- server = new UdpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(100,
- Charset.defaultCharset()));
- thread = server.startNewThread();
- }
-
- @AfterClass
- public static void tearDownClass() {
- server.shutdown();
- try {
- thread.join();
- } catch (final InterruptedException e) {
- // ignore
- }
- }
-
- public UdpXmlSocketServerTest() {
- super(Protocol.UDP, PORT, true);
- }
-
- @Override
- protected Layout<? extends Serializable> createLayout() {
- return super.createXmlLayout();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-server/pom.xml b/log4j-server/pom.xml
new file mode 100644
index 0000000..2833871
--- /dev/null
+++ b/log4j-server/pom.xml
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>2.8.2-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+ <artifactId>log4j-server</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Log4j Server components</name>
+ <description>The Apache Log4j server components</description>
+ <properties>
+ <log4jParentDir>${basedir}/..</log4jParentDir>
+ <projectDir>/log4j-server</projectDir>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ </dependency>
+ <!-- Command line for TCP and UDP servers -->
+ <dependency>
+ <groupId>com.beust</groupId>
+ <artifactId>jcommander</artifactId>
+ </dependency>
+
+ <!-- TEST DEPENDENCIES -->
+
+ <!-- Pull in useful test classes from API -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <!-- Include the standard NOTICE and LICENSE -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>org.apache.logging.log4j.core.net.*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changes-plugin</artifactId>
+ <version>${changes.plugin.version}</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>changes-report</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ <configuration>
+ <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
+ <useJql>true</useJql>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${checkstyle.plugin.version}</version>
+ <configuration>
+ <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
+ <configLocation>${log4jParentDir}/checkstyle.xml</configLocation>
+ <suppressionsLocation>${log4jParentDir}/checkstyle-suppressions.xml</suppressionsLocation>
+ <enableRulesSummary>false</enableRulesSummary>
+ <propertyExpansion>basedir=${basedir}</propertyExpansion>
+ <propertyExpansion>licensedir=${log4jParentDir}/checkstyle-header.txt</propertyExpansion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>${javadoc.plugin.version}</version>
+ <configuration>
+ <bottom><![CDATA[<p align="center">Copyright © {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.<br />
+ Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo,
+ and the Apache Log4j logo are trademarks of The Apache Software Foundation.</p>]]></bottom>
+ <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
+ project -->
+ <detectOfflineLinks>false</detectOfflineLinks>
+ <linksource>true</linksource>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <id>non-aggregate</id>
+ <reports>
+ <report>javadoc</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>${findbugs.plugin.version}</version>
+ <configuration>
+ <fork>true</fork>
+ <jvmArgs>-Duser.language=en</jvmArgs>
+ <threshold>Normal</threshold>
+ <effort>Default</effort>
+ <excludeFilterFile>${log4jParentDir}/findbugs-exclude-filter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>${jxr.plugin.version}</version>
+ <reportSets>
+ <reportSet>
+ <id>non-aggregate</id>
+ <reports>
+ <report>jxr</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>${pmd.plugin.version}</version>
+ <configuration>
+ <targetJdk>${maven.compiler.target}</targetJdk>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
+
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/AbstractJmsReceiver.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/AbstractJmsReceiver.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/AbstractJmsReceiver.java
new file mode 100644
index 0000000..753fc80
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/AbstractJmsReceiver.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.net.mom.jms;
+
+import org.apache.logging.log4j.core.net.server.JmsServer;
+
+/**
+ * Common JMS server functionality.
+ *
+ * @since 2.6
+ */
+public abstract class AbstractJmsReceiver {
+
+ /**
+ * Prints out usage information to {@linkplain System#err standard error}.
+ */
+ protected abstract void usage();
+
+ /**
+ * Executes a JmsServer with the given command line arguments.
+ *
+ * @param args command line arguments
+ * @throws Exception
+ */
+ protected void doMain(final String... args) throws Exception {
+ if (args.length != 4) {
+ usage();
+ System.exit(1);
+ }
+ final JmsServer server = new JmsServer(args[0], args[1], args[2], args[3]);
+ server.run();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsQueueReceiver.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsQueueReceiver.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsQueueReceiver.java
new file mode 100644
index 0000000..dac46d3
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsQueueReceiver.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.net.mom.jms;
+
+/**
+ * Receives Log Events over a JMS Queue. This implementation expects that all messages will
+ * contain a serialized LogEvent.
+ */
+public class JmsQueueReceiver extends AbstractJmsReceiver {
+
+ private JmsQueueReceiver() {
+ }
+
+ /**
+ * Main startup for the receiver.
+ *
+ * @param args The command line arguments.
+ * @throws Exception if an error occurs.
+ */
+ public static void main(final String[] args) throws Exception {
+ final JmsQueueReceiver receiver = new JmsQueueReceiver();
+ receiver.doMain(args);
+ }
+
+ @Override
+ protected void usage() {
+ System.err.println("Wrong number of arguments.");
+ System.err.println("Usage: java " + JmsQueueReceiver.class.getName()
+ + " QueueConnectionFactoryBindingName QueueBindingName username password");
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsTopicReceiver.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsTopicReceiver.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsTopicReceiver.java
new file mode 100644
index 0000000..4442ab1
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsTopicReceiver.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.net.mom.jms;
+
+/**
+ * Receives Topic messages that contain LogEvents. This implementation expects that all messages
+ * are serialized log events.
+ */
+public class JmsTopicReceiver extends AbstractJmsReceiver {
+
+ private JmsTopicReceiver() {
+ }
+
+ /**
+ * Main startup for the receiver.
+ *
+ * @param args The command line arguments.
+ * @throws Exception if an error occurs.
+ */
+ public static void main(final String[] args) throws Exception {
+ final JmsTopicReceiver receiver = new JmsTopicReceiver();
+ receiver.doMain(args);
+ }
+
+ @Override
+ protected void usage() {
+ System.err.println("Wrong number of arguments.");
+ System.err.println("Usage: java " + JmsTopicReceiver.class.getName()
+ + " TopicConnectionFactoryBindingName TopicBindingName username password");
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/package-info.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/package-info.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/package-info.java
new file mode 100644
index 0000000..9c3e03e
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/mom/jms/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+/**
+ * Supporting network code for JMS appenders.
+ *
+ * <p>Note that you can use JmsQueueReceiver or JmsTopicReceiver as executable main classes to receive log events over
+ * JMS (sent via the appropriate JMS appender) that can be subsequently logged according to the configuration given to
+ * the running process. Of course, use of these classes as standalone executables are entirely optional and can
+ * be used directly in your application (e.g., through your Spring {@code beans.xml} configuration).</p>
+ */
+package org.apache.logging.log4j.core.net.mom.jms;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/AbstractLogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/AbstractLogEventBridge.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/AbstractLogEventBridge.java
new file mode 100644
index 0000000..59b889b
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/AbstractLogEventBridge.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.status.StatusLogger;
+
+/**
+ * Abstract class for implementations of {@link LogEventBridge}.
+ *
+ * @param <T>
+ * The kind of input stream read
+ */
+public abstract class AbstractLogEventBridge<T extends InputStream> implements LogEventBridge<T> {
+
+ protected static final int END = -1;
+
+ protected static final Logger logger = StatusLogger.getLogger();
+
+ // The default is to return the same object as given.
+ @SuppressWarnings("unchecked")
+ @Override
+ public T wrapStream(final InputStream inputStream) throws IOException {
+ return (T) inputStream;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
new file mode 100644
index 0000000..9836694
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URL;
+import java.util.Objects;
+
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.validators.PositiveInteger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LogEventListener;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.ConfigurationSource;
+import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
+import org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory;
+import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
+import org.apache.logging.log4j.core.util.InetAddressConverter;
+import org.apache.logging.log4j.core.util.Log4jThread;
+import org.apache.logging.log4j.util.Strings;
+
+/**
+ * Abstract socket server for TCP and UDP implementations.
+ *
+ * @param <T>
+ * The kind of input stream read
+ *
+ * TODO Make a LifeCycle
+ */
+public abstract class AbstractSocketServer<T extends InputStream> extends LogEventListener implements Runnable {
+
+ protected static class CommandLineArguments extends BasicCommandLineArguments {
+
+ @Parameter(names = { "--config", "-c" }, description = "Log4j configuration file location (path or URL).")
+ private String configLocation;
+
+ @Parameter(names = { "--interactive",
+ "-i" }, description = "Accepts commands on standard input (\"exit\" is the only command).")
+ private boolean interactive;
+
+ @Parameter(names = { "--port",
+ "-p" }, validateWith = PositiveInteger.class, description = "Server socket port.")
+ private int port;
+
+ @Parameter(names = { "--localbindaddress",
+ "-a" }, converter = InetAddressConverter.class, description = "Server socket local bind address.")
+ private InetAddress localBindAddress;
+
+ String getConfigLocation() {
+ return configLocation;
+ }
+
+ int getPort() {
+ return port;
+ }
+
+ protected boolean isInteractive() {
+ return interactive;
+ }
+
+ void setConfigLocation(final String configLocation) {
+ this.configLocation = configLocation;
+ }
+
+ void setInteractive(final boolean interactive) {
+ this.interactive = interactive;
+ }
+
+ void setPort(final int port) {
+ this.port = port;
+ }
+
+ InetAddress getLocalBindAddress() {
+ return localBindAddress;
+ }
+
+ void setLocalBindAddress(final InetAddress localBindAddress) {
+ this.localBindAddress = localBindAddress;
+ }
+ }
+
+ /**
+ * Factory that creates a Configuration for the server.
+ */
+ protected static class ServerConfigurationFactory extends XmlConfigurationFactory {
+
+ private final String path;
+
+ public ServerConfigurationFactory(final String path) {
+ this.path = path;
+ }
+
+ @Override
+ public Configuration getConfiguration(final LoggerContext loggerContext, final String name,
+ final URI configLocation) {
+ if (Strings.isNotEmpty(path)) {
+ File file = null;
+ ConfigurationSource source = null;
+ try {
+ file = new File(path);
+ final FileInputStream is = new FileInputStream(file);
+ source = new ConfigurationSource(is, file);
+ } catch (final FileNotFoundException ignored) {
+ // Ignore this error
+ }
+ if (source == null) {
+ try {
+ final URL url = new URL(path);
+ source = new ConfigurationSource(url.openStream(), url);
+ } catch (final IOException ignored) {
+ // Ignore this error
+ }
+ }
+
+ try {
+ if (source != null) {
+ return new XmlConfiguration(loggerContext, source);
+ }
+ } catch (final Exception ignored) {
+ // Ignore this error.
+ }
+ System.err.println("Unable to process configuration at " + path + ", using default.");
+ }
+ return super.getConfiguration(loggerContext, name, configLocation);
+ }
+ }
+
+ protected static final int MAX_PORT = 65534;
+
+ private volatile boolean active = true;
+
+ protected final LogEventBridge<T> logEventInput;
+
+ protected final Logger logger;
+
+ /**
+ * Creates a new socket server.
+ *
+ * @param port
+ * listen to this port
+ * @param logEventInput
+ * Use this input to read log events.
+ */
+ public AbstractSocketServer(final int port, final LogEventBridge<T> logEventInput) {
+ this.logger = LogManager.getLogger(this.getClass().getName() + '.' + port);
+ this.logEventInput = Objects.requireNonNull(logEventInput, "LogEventInput");
+ }
+
+ protected boolean isActive() {
+ return this.active;
+ }
+
+ protected void setActive(final boolean isActive) {
+ this.active = isActive;
+ }
+
+ /**
+ * Start this server in a new thread.
+ *
+ * @return the new thread that running this server.
+ */
+ public Thread startNewThread() {
+ final Thread thread = new Log4jThread(this);
+ thread.start();
+ return thread;
+ }
+
+ public abstract void shutdown() throws Exception;
+
+ public void awaitTermination(final Thread serverThread) throws Exception {
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
+ while (true) {
+ final String line = reader.readLine();
+ if (line == null
+ || line.equalsIgnoreCase("quit")
+ || line.equalsIgnoreCase("stop")
+ || line.equalsIgnoreCase("exit")) {
+ this.shutdown();
+ serverThread.join();
+ break;
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/InputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/InputStreamLogEventBridge.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/InputStreamLogEventBridge.java
new file mode 100644
index 0000000..11b4aa4
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/InputStreamLogEventBridge.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LogEventListener;
+import org.apache.logging.log4j.core.impl.Log4jLogEvent;
+import org.apache.logging.log4j.util.Strings;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+
+/**
+ * Reads and logs {@link LogEvent}s from an {@link InputStream}.
+ */
+public abstract class InputStreamLogEventBridge extends AbstractLogEventBridge<InputStream> {
+
+ private final int bufferSize;
+
+ private final Charset charset;
+
+ private final String eventEndMarker;
+
+ private final ObjectReader objectReader;
+
+ public InputStreamLogEventBridge(final ObjectMapper mapper, final int bufferSize, final Charset charset, final String eventEndMarker) {
+ this.bufferSize = bufferSize;
+ this.charset = charset;
+ this.eventEndMarker = eventEndMarker;
+ this.objectReader = mapper.readerFor(Log4jLogEvent.class);
+ }
+
+ abstract protected int[] getEventIndices(final String text, int beginIndex);
+
+ @Override
+ public void logEvents(final InputStream inputStream, final LogEventListener logEventListener) throws IOException {
+ String workingText = Strings.EMPTY;
+ try {
+ // Allocate buffer once
+ final byte[] buffer = new byte[bufferSize];
+ String textRemains = workingText = Strings.EMPTY;
+ while (true) {
+ // Process until the stream is EOF.
+ final int streamReadLength = inputStream.read(buffer);
+ if (streamReadLength == END) {
+ // The input stream is EOF
+ break;
+ }
+ final String text = workingText = textRemains + new String(buffer, 0, streamReadLength, charset);
+ int beginIndex = 0;
+ while (true) {
+ // Extract and log all XML events in the buffer
+ final int[] pair = getEventIndices(text, beginIndex);
+ final int eventStartMarkerIndex = pair[0];
+ if (eventStartMarkerIndex < 0) {
+ // No more events or partial XML only in the buffer.
+ // Save the unprocessed string part
+ textRemains = text.substring(beginIndex);
+ break;
+ }
+ final int eventEndMarkerIndex = pair[1];
+ if (eventEndMarkerIndex > 0) {
+ final int eventEndXmlIndex = eventEndMarkerIndex + eventEndMarker.length();
+ final String textEvent = workingText = text.substring(eventStartMarkerIndex, eventEndXmlIndex);
+ final LogEvent logEvent = unmarshal(textEvent);
+ logEventListener.log(logEvent);
+ beginIndex = eventEndXmlIndex;
+ } else {
+ // No more events or partial XML only in the buffer.
+ // Save the unprocessed string part
+ textRemains = text.substring(beginIndex);
+ break;
+ }
+ }
+ }
+ } catch (final IOException ex) {
+ logger.error(workingText, ex);
+ }
+ }
+
+ protected Log4jLogEvent unmarshal(final String jsonEvent) throws IOException {
+ return this.objectReader.readValue(jsonEvent);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
new file mode 100644
index 0000000..05fb113
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.ObjectMessage;
+
+import org.apache.logging.log4j.LoggingException;
+import org.apache.logging.log4j.core.AbstractLifeCycle;
+import org.apache.logging.log4j.core.LifeCycle2;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LogEventListener;
+import org.apache.logging.log4j.core.appender.mom.JmsManager;
+import org.apache.logging.log4j.core.net.JndiManager;
+
+/**
+ * LogEventListener server that receives LogEvents over a JMS {@link javax.jms.Destination}.
+ *
+ * @since 2.1
+ */
+public class JmsServer extends LogEventListener implements MessageListener, LifeCycle2 {
+
+ private final AtomicReference<State> state = new AtomicReference<>(State.INITIALIZED);
+ private final JmsManager jmsManager;
+ private MessageConsumer messageConsumer;
+
+ public JmsServer(final String connectionFactoryBindingName,
+ final String destinationBindingName,
+ final String username,
+ final String password) {
+ final String managerName = JmsServer.class.getName() + '@' + JmsServer.class.hashCode();
+ final JndiManager jndiManager = JndiManager.getDefaultManager(managerName);
+ jmsManager = JmsManager.getJmsManager(managerName, jndiManager, connectionFactoryBindingName,
+ destinationBindingName, username, password);
+ }
+
+ @Override
+ public State getState() {
+ return state.get();
+ }
+
+ @Override
+ public void onMessage(final Message message) {
+ try {
+ if (message instanceof ObjectMessage) {
+ final Object body = ((ObjectMessage) message).getObject();
+ if (body instanceof LogEvent) {
+ log((LogEvent) body);
+ } else {
+ LOGGER.warn("Expected ObjectMessage to contain LogEvent. Got type {} instead.", body.getClass());
+ }
+ } else {
+ LOGGER.warn("Received message of type {} and JMSType {} which cannot be handled.", message.getClass(),
+ message.getJMSType());
+ }
+ } catch (final JMSException e) {
+ LOGGER.catching(e);
+ }
+ }
+
+ @Override
+ public void initialize() {
+ }
+
+ @Override
+ public void start() {
+ if (state.compareAndSet(State.INITIALIZED, State.STARTING)) {
+ try {
+ messageConsumer = jmsManager.createMessageConsumer();
+ messageConsumer.setMessageListener(this);
+ } catch (final JMSException e) {
+ throw new LoggingException(e);
+ }
+ }
+ }
+
+ @Override
+ public void stop() {
+ stop(AbstractLifeCycle.DEFAULT_STOP_TIMEOUT, AbstractLifeCycle.DEFAULT_STOP_TIMEUNIT);
+ }
+
+ @Override
+ public boolean stop(final long timeout, final TimeUnit timeUnit) {
+ boolean stopped = true;
+ try {
+ messageConsumer.close();
+ } catch (final JMSException e) {
+ LOGGER.debug("Exception closing {}", messageConsumer, e);
+ stopped = false;
+ }
+ return stopped && jmsManager.stop(timeout, timeUnit);
+ }
+
+ @Override
+ public boolean isStarted() {
+ return state.get() == State.STARTED;
+ }
+
+ @Override
+ public boolean isStopped() {
+ return state.get() == State.STOPPED;
+ }
+
+ /**
+ * Starts and runs this server until the user types "exit" into standard input.
+ *
+ * @throws IOException
+ * @since 2.6
+ */
+ public void run() throws IOException {
+ this.start();
+ System.out.println("Type \"exit\" to quit.");
+ final BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in, Charset.defaultCharset()));
+ while (true) {
+ final String line = stdin.readLine();
+ if (line == null || line.equalsIgnoreCase("exit")) {
+ System.out.println("Exiting. Kill the application if it does not exit due to daemon threads.");
+ this.stop();
+ return;
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/JsonInputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/JsonInputStreamLogEventBridge.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/JsonInputStreamLogEventBridge.java
new file mode 100644
index 0000000..a0e4fdb
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/JsonInputStreamLogEventBridge.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.jackson.Log4jJsonObjectMapper;
+import org.apache.logging.log4j.util.Chars;
+
+/**
+ * Reads and logs JSON {@link LogEvent}s from an {@link InputStream}..
+ */
+public class JsonInputStreamLogEventBridge extends InputStreamLogEventBridge {
+
+ private static final int[] END_PAIR = new int[] { END, END };
+ private static final char EVENT_END_MARKER = '}';
+ private static final char EVENT_START_MARKER = '{';
+ private static final char JSON_ESC = '\\';
+ private static final char JSON_STR_DELIM = Chars.DQUOTE;
+ private static final boolean THREAD_CONTEXT_MAP_AS_LIST = false;
+
+ public JsonInputStreamLogEventBridge() {
+ this(1024, Charset.defaultCharset());
+ }
+
+ public JsonInputStreamLogEventBridge(final int bufferSize, final Charset charset) {
+ super(new Log4jJsonObjectMapper(THREAD_CONTEXT_MAP_AS_LIST, true), bufferSize, charset,
+ String.valueOf(EVENT_END_MARKER));
+ }
+
+ @Override
+ protected int[] getEventIndices(final String text, final int beginIndex) {
+ // Scan the text for the end of the next JSON object.
+ final int start = text.indexOf(EVENT_START_MARKER, beginIndex);
+ if (start == END) {
+ return END_PAIR;
+ }
+ final char[] charArray = text.toCharArray();
+ int stack = 0;
+ boolean inStr = false;
+ boolean inEsc = false;
+ for (int i = start; i < charArray.length; i++) {
+ final char c = charArray[i];
+ if (inEsc) {
+ // Skip this char and continue
+ inEsc = false;
+ } else {
+ switch (c) {
+ case EVENT_START_MARKER:
+ if (!inStr) {
+ stack++;
+ }
+ break;
+ case EVENT_END_MARKER:
+ if (!inStr) {
+ stack--;
+ }
+ break;
+ case JSON_STR_DELIM:
+ inStr = !inStr;
+ break;
+ case JSON_ESC:
+ inEsc = true;
+ break;
+ }
+ if (stack == 0) {
+ return new int[] { start, i };
+ }
+ }
+ }
+ return END_PAIR;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/LogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/LogEventBridge.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/LogEventBridge.java
new file mode 100644
index 0000000..ba45bb6
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/LogEventBridge.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LogEventListener;
+
+/**
+ * Reads {@link LogEvent}s from the given input stream and logs them as they are discovered on the given logger.
+ *
+ * <p>
+ * Should be stateless.
+ * </p>
+ *
+ * @param <T>
+ * The kind of {@link InputStream} to wrap and read.
+ */
+public interface LogEventBridge<T extends InputStream> {
+
+ /**
+ * Reads {@link LogEvent}s from the given input stream and logs them as they are discovered on the given logger.
+ *
+ * @param inputStream
+ * the input stream to read
+ * @param logEventListener
+ * TODO
+ * @throws IOException
+ */
+ void logEvents(T inputStream, LogEventListener logEventListener) throws IOException;
+
+ /**
+ * Wraps the given stream if needed.
+ *
+ * @param inputStream
+ * the stream to wrap
+ * @return the wrapped stream or the given stream.
+ * @throws IOException
+ */
+ T wrapStream(InputStream inputStream) throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/ObjectInputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/ObjectInputStreamLogEventBridge.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/ObjectInputStreamLogEventBridge.java
new file mode 100644
index 0000000..059f069
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/ObjectInputStreamLogEventBridge.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LogEventListener;
+
+/**
+ * Reads and logs serialized {@link LogEvent} objects from an {@link ObjectInputStream}.
+ */
+public class ObjectInputStreamLogEventBridge extends AbstractLogEventBridge<ObjectInputStream> {
+
+ @Override
+ public void logEvents(final ObjectInputStream inputStream, final LogEventListener logEventListener)
+ throws IOException {
+ try {
+ logEventListener.log((LogEvent) inputStream.readObject());
+ } catch (final ClassNotFoundException e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public ObjectInputStream wrapStream(final InputStream inputStream) throws IOException {
+ return new ObjectInputStream(inputStream);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/SecureTcpSocketServer.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/SecureTcpSocketServer.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/SecureTcpSocketServer.java
new file mode 100644
index 0000000..87390e8
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/SecureTcpSocketServer.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.logging.log4j.core.net.ssl.SslConfiguration;
+
+/**
+ * Listens for events over a secure socket connection (SSL/TLS).
+ *
+ * @param <T>
+ * The kind of input stream read
+ */
+public class SecureTcpSocketServer<T extends InputStream> extends TcpSocketServer<T> {
+
+ public SecureTcpSocketServer(final int port, final LogEventBridge<T> logEventInput,
+ final SslConfiguration sslConfig) throws IOException {
+ super(port, logEventInput, sslConfig.getSslServerSocketFactory().createServerSocket(port));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/TcpSocketServer.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/TcpSocketServer.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/TcpSocketServer.java
new file mode 100644
index 0000000..68ac1ba
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/TcpSocketServer.java
@@ -0,0 +1,314 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.OptionalDataException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.validators.PositiveInteger;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
+import org.apache.logging.log4j.core.util.Closer;
+import org.apache.logging.log4j.core.util.Log4jThread;
+import org.apache.logging.log4j.message.EntryMessage;
+
+/**
+ * Listens for Log4j events on a TCP server socket and passes them on to Log4j.
+ *
+ * @param <T>
+ * The kind of input stream read
+ * @see #main(String[])
+ */
+public class TcpSocketServer<T extends InputStream> extends AbstractSocketServer<T> {
+
+ protected static class CommandLineArguments extends AbstractSocketServer.CommandLineArguments {
+
+ @Parameter(names = { "--backlog",
+ "-b" }, validateWith = PositiveInteger.class, description = "Server socket backlog.")
+ // Same default as ServerSocket
+ private int backlog = 50;
+
+ int getBacklog() {
+ return backlog;
+ }
+
+ void setBacklog(final int backlog) {
+ this.backlog = backlog;
+ }
+
+ }
+
+ /**
+ * Thread that processes the events.
+ */
+ private class SocketHandler extends Log4jThread {
+
+ private final T inputStream;
+
+ private volatile boolean shutdown = false;
+
+ public SocketHandler(final Socket socket) throws IOException {
+ this.inputStream = logEventInput.wrapStream(socket.getInputStream());
+ }
+
+ @Override
+ public void run() {
+ final EntryMessage entry = logger.traceEntry();
+ boolean closed = false;
+ try {
+ try {
+ while (!shutdown) {
+ logEventInput.logEvents(inputStream, TcpSocketServer.this);
+ }
+ } catch (final EOFException e) {
+ closed = true;
+ } catch (final OptionalDataException e) {
+ logger.error("OptionalDataException eof=" + e.eof + " length=" + e.length, e);
+ } catch (final IOException e) {
+ logger.error("IOException encountered while reading from socket", e);
+ }
+ if (!closed) {
+ Closer.closeSilently(inputStream);
+ }
+ } finally {
+ handlers.remove(Long.valueOf(getId()));
+ }
+ logger.traceExit(entry);
+ }
+
+ public void shutdown() {
+ this.shutdown = true;
+ interrupt();
+ }
+ }
+
+ /**
+ * Creates a socket server that reads JSON log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static TcpSocketServer<InputStream> createJsonSocketServer(final int port) throws IOException {
+ LOGGER.entry("createJsonSocketServer", port);
+ final TcpSocketServer<InputStream> socketServer = new TcpSocketServer<>(port, new JsonInputStreamLogEventBridge());
+ return LOGGER.exit(socketServer);
+ }
+
+ /**
+ * Creates a socket server that reads serialized log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static TcpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port) throws IOException {
+ LOGGER.entry(port);
+ final TcpSocketServer<ObjectInputStream> socketServer = new TcpSocketServer<>(port, new ObjectInputStreamLogEventBridge());
+ return LOGGER.exit(socketServer);
+ }
+
+ /**
+ * Creates a socket server that reads serialized log events.
+ *
+ * @param port the port to listen
+ * @param localBindAddress The server socket's local bin address
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ * @since 2.7
+ */
+ public static TcpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port, final int backlog,
+ final InetAddress localBindAddress) throws IOException {
+ LOGGER.entry(port);
+ final TcpSocketServer<ObjectInputStream> socketServer = new TcpSocketServer<>(port, backlog, localBindAddress,
+ new ObjectInputStreamLogEventBridge());
+ return LOGGER.exit(socketServer);
+ }
+
+ /**
+ * Creates a socket server that reads XML log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static TcpSocketServer<InputStream> createXmlSocketServer(final int port) throws IOException {
+ LOGGER.entry(port);
+ final TcpSocketServer<InputStream> socketServer = new TcpSocketServer<>(port, new XmlInputStreamLogEventBridge());
+ return LOGGER.exit(socketServer);
+ }
+
+ /**
+ * Main startup for the server. Run with "--help" for to print command line help on the console.
+ *
+ * @param args
+ * The command line arguments.
+ * @throws Exception
+ * if an error occurs.
+ */
+ public static void main(final String[] args) throws Exception {
+ final CommandLineArguments cla = BasicCommandLineArguments.parseCommandLine(args, TcpSocketServer.class, new CommandLineArguments());
+ if (cla.isHelp()) {
+ return;
+ }
+ if (cla.getConfigLocation() != null) {
+ ConfigurationFactory.setConfigurationFactory(new ServerConfigurationFactory(cla.getConfigLocation()));
+ }
+ final TcpSocketServer<ObjectInputStream> socketServer = TcpSocketServer
+ .createSerializedSocketServer(cla.getPort(), cla.getBacklog(), cla.getLocalBindAddress());
+ final Thread serverThread = socketServer.startNewThread();
+ if (cla.isInteractive()) {
+ socketServer.awaitTermination(serverThread);
+ }
+ }
+
+ private final ConcurrentMap<Long, SocketHandler> handlers = new ConcurrentHashMap<>();
+
+ private final ServerSocket serverSocket;
+
+ /**
+ * Constructor.
+ *
+ * @param port
+ * The server socket port.
+ * @param backlog
+ * The server socket backlog.
+ * @param localBindAddress TODO
+ * @param logEventInput
+ * the log even input
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ * @since 2.7
+ */
+ @SuppressWarnings("resource")
+ public TcpSocketServer(final int port, final int backlog, final InetAddress localBindAddress, final LogEventBridge<T> logEventInput) throws IOException {
+ this(port, logEventInput, new ServerSocket(port, backlog, localBindAddress));
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param port
+ * to listen.
+ * @param logEventInput
+ * the log even input
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public TcpSocketServer(final int port, final LogEventBridge<T> logEventInput) throws IOException {
+ this(port, logEventInput, extracted(port));
+ }
+
+ private static ServerSocket extracted(final int port) throws IOException {
+ return new ServerSocket(port);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param port
+ * to listen.
+ * @param logEventInput
+ * the log even input
+ * @param serverSocket
+ * the socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public TcpSocketServer(final int port, final LogEventBridge<T> logEventInput, final ServerSocket serverSocket)
+ throws IOException {
+ super(port, logEventInput);
+ this.serverSocket = serverSocket;
+ }
+
+ /**
+ * Accept incoming events and processes them.
+ */
+ @Override
+ public void run() {
+ final EntryMessage entry = logger.traceEntry();
+ while (isActive()) {
+ if (serverSocket.isClosed()) {
+ return;
+ }
+ try {
+ // Accept incoming connections.
+ logger.debug("Listening for a connection {}...", serverSocket);
+ final Socket clientSocket = serverSocket.accept();
+ logger.debug("Acepted connection on {}...", serverSocket);
+ logger.debug("Socket accepted: {}", clientSocket);
+ clientSocket.setSoLinger(true, 0);
+
+ // accept() will block until a client connects to the server.
+ // If execution reaches this point, then it means that a client
+ // socket has been accepted.
+
+ final SocketHandler handler = new SocketHandler(clientSocket);
+ handlers.put(Long.valueOf(handler.getId()), handler);
+ handler.start();
+ } catch (final IOException e) {
+ if (serverSocket.isClosed()) {
+ // OK we're done.
+ logger.traceExit(entry);
+ return;
+ }
+ logger.error("Exception encountered on accept. Ignoring. Stack trace :", e);
+ }
+ }
+ for (final Map.Entry<Long, SocketHandler> handlerEntry : handlers.entrySet()) {
+ final SocketHandler handler = handlerEntry.getValue();
+ handler.shutdown();
+ try {
+ handler.join();
+ } catch (final InterruptedException ignored) {
+ // Ignore the exception
+ }
+ }
+ logger.traceExit(entry);
+ }
+
+ /**
+ * Shutdown the server.
+ *
+ * @throws IOException if the server socket could not be closed
+ */
+ @Override
+ public void shutdown() throws IOException {
+ final EntryMessage entry = logger.traceEntry();
+ setActive(false);
+ Thread.currentThread().interrupt();
+ serverSocket.close();
+ logger.traceExit(entry);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/UdpSocketServer.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/UdpSocketServer.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/UdpSocketServer.java
new file mode 100644
index 0000000..ed04f69
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/UdpSocketServer.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.ByteArrayInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.OptionalDataException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
+
+/**
+ * Listens for Log4j events on a datagram socket and passes them on to Log4j.
+ *
+ * @param <T>
+ * The kind of input stream read
+ * @see #main(String[])
+ */
+public class UdpSocketServer<T extends InputStream> extends AbstractSocketServer<T> {
+
+ /**
+ * Creates a socket server that reads JSON log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static UdpSocketServer<InputStream> createJsonSocketServer(final int port) throws IOException {
+ return new UdpSocketServer<>(port, new JsonInputStreamLogEventBridge());
+ }
+
+ /**
+ * Creates a socket server that reads serialized log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static UdpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port) throws IOException {
+ return new UdpSocketServer<>(port, new ObjectInputStreamLogEventBridge());
+ }
+
+ /**
+ * Creates a socket server that reads XML log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static UdpSocketServer<InputStream> createXmlSocketServer(final int port) throws IOException {
+ return new UdpSocketServer<>(port, new XmlInputStreamLogEventBridge());
+ }
+
+ /**
+ * Main startup for the server. Run with "--help" for to print command line help on the console.
+ *
+ * @param args
+ * The command line arguments.
+ * @throws Exception
+ * if an error occurs.
+ */
+ public static void main(final String[] args) throws Exception {
+ final CommandLineArguments cla = BasicCommandLineArguments.parseCommandLine(args, UdpSocketServer.class, new CommandLineArguments());
+ if (cla.isHelp()) {
+ return;
+ }
+ if (cla.getConfigLocation() != null) {
+ ConfigurationFactory.setConfigurationFactory(new ServerConfigurationFactory(cla.getConfigLocation()));
+ }
+ final UdpSocketServer<ObjectInputStream> socketServer = UdpSocketServer
+ .createSerializedSocketServer(cla.getPort());
+ final Thread serverThread = socketServer.startNewThread();
+ if (cla.isInteractive()) {
+ socketServer.awaitTermination(serverThread);
+ }
+ }
+
+ private final DatagramSocket datagramSocket;
+
+ // max size so we only have to deal with one packet
+ private final int maxBufferSize = 1024 * 65 + 1024;
+
+ /**
+ * Constructor.
+ *
+ * @param port
+ * to listen on.
+ * @param logEventInput
+ * @throws IOException
+ * If an error occurs.
+ */
+ public UdpSocketServer(final int port, final LogEventBridge<T> logEventInput) throws IOException {
+ super(port, logEventInput);
+ this.datagramSocket = new DatagramSocket(port);
+ }
+
+ /**
+ * Accept incoming events and processes them.
+ */
+ @Override
+ public void run() {
+ while (isActive()) {
+ if (datagramSocket.isClosed()) {
+ // OK we're done.
+ return;
+ }
+ try {
+ final byte[] buf = new byte[maxBufferSize];
+ final DatagramPacket packet = new DatagramPacket(buf, buf.length);
+ datagramSocket.receive(packet);
+ final ByteArrayInputStream bais = new ByteArrayInputStream(packet.getData(), packet.getOffset(), packet.getLength());
+ logEventInput.logEvents(logEventInput.wrapStream(bais), this);
+ } catch (final OptionalDataException e) {
+ if (datagramSocket.isClosed()) {
+ // OK we're done.
+ return;
+ }
+ logger.error("OptionalDataException eof=" + e.eof + " length=" + e.length, e);
+ } catch (final EOFException e) {
+ if (datagramSocket.isClosed()) {
+ // OK we're done.
+ return;
+ }
+ logger.info("EOF encountered");
+ } catch (final IOException e) {
+ if (datagramSocket.isClosed()) {
+ // OK we're done.
+ return;
+ }
+ logger.error("Exception encountered on accept. Ignoring. Stack Trace :", e);
+ }
+ }
+ }
+
+ /**
+ * Shutdown the server.
+ */
+ @Override
+ public void shutdown() {
+ this.setActive(false);
+ Thread.currentThread().interrupt();
+ datagramSocket.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/XmlInputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/XmlInputStreamLogEventBridge.java b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/XmlInputStreamLogEventBridge.java
new file mode 100644
index 0000000..7853398
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/core/net/server/XmlInputStreamLogEventBridge.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.net.server;
+
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.jackson.Log4jXmlObjectMapper;
+
+/**
+ * Reads and logs {@link LogEvent}s from an {@link InputStream}.
+ */
+public class XmlInputStreamLogEventBridge extends InputStreamLogEventBridge {
+
+ private static final String EVENT_END = "</Event>";
+ private static final String EVENT_START_NS_N = "<Event>";
+ private static final String EVENT_START_NS_Y = "<Event ";
+
+ public XmlInputStreamLogEventBridge() {
+ this(1024, Charset.defaultCharset());
+ }
+
+ public XmlInputStreamLogEventBridge(final int bufferSize, final Charset charset) {
+ super(new Log4jXmlObjectMapper(), bufferSize, charset, EVENT_END);
+ }
+
+ @Override
+ protected int[] getEventIndices(final String text, final int beginIndex) {
+ int start = text.indexOf(EVENT_START_NS_Y, beginIndex);
+ int startLen = EVENT_START_NS_Y.length();
+ if (start < 0) {
+ start = text.indexOf(EVENT_START_NS_N, beginIndex);
+ startLen = EVENT_START_NS_N.length();
+ }
+ final int end = start < 0 ? -1 : text.indexOf(EVENT_END, start + startLen);
+ return new int[] { start, end };
+ }
+
+}
[09/14] logging-log4j2 git commit: Update runtime dependencies
Posted by mi...@apache.org.
Update runtime dependencies
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/3b89ec70
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/3b89ec70
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3b89ec70
Branch: refs/heads/master
Commit: 3b89ec70deed7dcad207935a1345abb9505ab82b
Parents: 179ad05
Author: Mikael St�ldal <mi...@magine.com>
Authored: Fri Mar 17 16:19:16 2017 +0100
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Fri Mar 17 16:19:16 2017 +0100
----------------------------------------------------------------------
src/site/xdoc/runtime-dependencies.xml | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3b89ec70/src/site/xdoc/runtime-dependencies.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/runtime-dependencies.xml b/src/site/xdoc/runtime-dependencies.xml
index 93e5470..4f5d410 100644
--- a/src/site/xdoc/runtime-dependencies.xml
+++ b/src/site/xdoc/runtime-dependencies.xml
@@ -142,13 +142,6 @@
distribution.
</td>
</tr>
- <tr>
- <td>TcpSocketServer and UdpSocketServer</td>
- <td>
- TcpSocketServer and UdpSocketServer use the <a href="http://www.jcommander.org/">JCommander</a> library
- which is licensed under the terms of the Apache License version 2.0.
- </td>
- </tr>
</table>
<a name="log4j-jcl" />
@@ -264,6 +257,20 @@
This only requires the Log4j API.
</p>
+ <a name="log4j-server" />
+ <h4>log4j-server</h4>
+ <table>
+ <caption align="top">Optional Dependencies per Feature in Log4J Server components</caption>
+ <tr>
+ <th>Feature</th>
+ <th>Requirements</th>
+ </tr>
+ <tr>
+ <td>JMS receivers</td>
+ <td>a JMS broker like <a href="http://activemq.apache.org/">Apache ActiveMQ</a></td>
+ </tr>
+ </table>
+
<a name="log4j-api-scala" />
<h4>log4j-api-scala</h4>
<p>
[04/14] logging-log4j2 git commit: Merge branch 'master' into
log4j-server
Posted by mi...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/AbstractSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/AbstractSocketServerTest.java
index 0000000,0000000..dfc44ea
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/AbstractSocketServerTest.java
@@@ -1,0 -1,0 +1,237 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.Serializable;
++import java.util.Arrays;
++import java.util.List;
++import java.util.Map;
++
++import org.apache.logging.log4j.Level;
++import org.apache.logging.log4j.core.Appender;
++import org.apache.logging.log4j.core.Filter;
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.Logger;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.appender.AppenderLoggingException;
++import org.apache.logging.log4j.core.appender.ConsoleAppender;
++import org.apache.logging.log4j.core.appender.SocketAppender;
++import org.apache.logging.log4j.core.layout.JsonLayout;
++import org.apache.logging.log4j.core.layout.PatternLayout;
++import org.apache.logging.log4j.core.layout.XmlLayout;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.apache.logging.log4j.test.AvailablePortFinder;
++import org.apache.logging.log4j.test.appender.ListAppender;
++import org.junit.After;
++import org.junit.Ignore;
++import org.junit.Test;
++
++import static org.junit.Assert.*;
++
++/**
++ *
++ */
++public abstract class AbstractSocketServerTest {
++
++ protected static Thread thread;
++
++ private static final String MESSAGE = "This is test message";
++
++ private static final String MESSAGE_2 = "This is test message 2";
++
++ private static final String MESSAGE_WITH_SPECIAL_CHARS = "{This}\n[is]\"n\"a\"\r\ntrue:\n\ttest,\nmessage";
++
++ static final int PORT_NUM = AvailablePortFinder.getNextAvailable();
++
++ static final int PORT = PORT_NUM;
++
++ private final LoggerContext ctx = LoggerContext.getContext(false);
++
++ private final boolean expectLengthException;
++
++ protected final int port;
++
++ protected final Protocol protocol;
++
++ private final Logger rootLogger = ctx.getLogger(AbstractSocketServerTest.class.getSimpleName());
++
++ protected AbstractSocketServerTest(final Protocol protocol, final int port, final boolean expectLengthException) {
++ this.protocol = protocol;
++ this.port = port;
++ this.expectLengthException = expectLengthException;
++ }
++
++ protected Layout<String> createJsonLayout() {
++ // @formatter: off
++ return JsonLayout.newBuilder()
++ .setLocationInfo(true)
++ .setProperties(true)
++ .setPropertiesAsList(false)
++ .setComplete(false)
++ .setCompact(false)
++ .setEventEol(false)
++ .setIncludeStacktrace(true)
++ .build();
++ // @formatter: on
++
++ //return JsonLayout.createLayout(null, true, true, false, false, false, false, null, null, null, true);
++ }
++
++ protected abstract Layout<? extends Serializable> createLayout();
++
++ protected Layout<? extends Serializable> createSerializedLayout() {
++ return null;
++ }
++
++ protected Layout<String> createXmlLayout() {
++ return XmlLayout.createLayout(true, true, false, false, null, true);
++ }
++
++ @After
++ public void tearDown() {
++ final Map<String, Appender> map = rootLogger.getAppenders();
++ for (final Map.Entry<String, Appender> entry : map.entrySet()) {
++ final Appender appender = entry.getValue();
++ rootLogger.removeAppender(appender);
++ appender.stop();
++ }
++ }
++
++ @Test
++ @Ignore("Broken test?")
++ public void test1000ShortMessages() throws Exception {
++ testServer(1000);
++ }
++
++ @Test
++ @Ignore("Broken test?")
++ public void test100ShortMessages() throws Exception {
++ testServer(100);
++ }
++
++ @Test
++ public void test10ShortMessages() throws Exception {
++ testServer(10);
++ }
++
++ @Test
++ public void test1ShortMessages() throws Exception {
++ testServer(1);
++ }
++
++ @Test
++ public void test2ShortMessages() throws Exception {
++ testServer(2);
++ }
++
++ @Test
++ public void test64KBMessages() throws Exception {
++ final char[] a64K = new char[1024 * 64];
++ Arrays.fill(a64K, 'a');
++ final String m1 = new String(a64K);
++ final String m2 = MESSAGE_2 + m1;
++ if (expectLengthException) {
++ try {
++ testServer(m1, m2);
++ } catch (final AppenderLoggingException are) {
++ assertTrue("", are.getCause() != null && are.getCause() instanceof IOException);
++ // Failure expected.
++ }
++ } else {
++ testServer(m1, m2);
++ }
++ }
++
++
++ @Test
++ public void testMessagesWithSpecialChars() throws Exception {
++ testServer(MESSAGE_WITH_SPECIAL_CHARS);
++ }
++
++
++ private void testServer(final int size) throws Exception {
++ final String[] messages = new String[size];
++ for (int i = 0; i < messages.length; i++) {
++ messages[i] = MESSAGE + " " + i;
++ }
++ testServer(messages);
++ }
++
++ protected void testServer(final String... messages) throws Exception {
++ final Filter socketFilter = new ThreadNameFilter(Filter.Result.NEUTRAL, Filter.Result.DENY);
++ final Filter serverFilter = new ThreadNameFilter(Filter.Result.DENY, Filter.Result.NEUTRAL);
++ final Layout<? extends Serializable> socketLayout = createLayout();
++ final SocketAppender socketAppender = createSocketAppender(socketFilter, socketLayout);
++ socketAppender.start();
++ final ListAppender listAppender = new ListAppender("Events", serverFilter, null, false, false);
++ listAppender.start();
++ final PatternLayout layout = PatternLayout.newBuilder().withPattern("%m %ex%n").build();
++ final ConsoleAppender console = ConsoleAppender.createDefaultAppenderForLayout(layout);
++ final Logger serverLogger = ctx.getLogger(this.getClass().getName());
++ serverLogger.addAppender(console);
++ serverLogger.setAdditive(false);
++
++ // set appender on root and set level to debug
++ rootLogger.addAppender(socketAppender);
++ rootLogger.addAppender(listAppender);
++ rootLogger.setAdditive(false);
++ rootLogger.setLevel(Level.DEBUG);
++ for (final String message : messages) {
++ rootLogger.debug(message);
++ }
++ final int MAX_TRIES = 400;
++ for (int i = 0; i < MAX_TRIES; i++) {
++ if (listAppender.getEvents().size() < messages.length) {
++ try {
++ // Let the server-side read the messages.
++ Thread.sleep(50);
++ } catch (final Exception e) {
++ e.printStackTrace();
++ }
++ } else {
++ break;
++ }
++ }
++ final List<LogEvent> events = listAppender.getEvents();
++ assertNotNull("No event retrieved", events);
++ assertEquals("Incorrect number of events received", messages.length, events.size());
++ for (int i = 0; i < messages.length; i++) {
++ assertTrue("Incorrect event", events.get(i).getMessage().getFormattedMessage().equals(messages[i]));
++ }
++ }
++
++ protected SocketAppender createSocketAppender(final Filter socketFilter,
++ final Layout<? extends Serializable> socketLayout) {
++ // @formatter:off
++ return SocketAppender.newBuilder()
++ .withProtocol(this.protocol)
++ .withHost("localhost")
++ .withPort(this.port)
++ .withReconnectDelayMillis(-1)
++ .withName("test")
++ .withImmediateFlush(true)
++ .withImmediateFail(false)
++ .withIgnoreExceptions(false)
++ .withLayout(socketLayout)
++ .withFilter(socketFilter)
++ .build();
++ // @formatter:on
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/SslXmlSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/SslXmlSocketServerTest.java
index 0000000,0000000..1a51244
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/SslXmlSocketServerTest.java
@@@ -1,0 -1,0 +1,104 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.InputStream;
++import java.io.Serializable;
++import java.nio.charset.Charset;
++
++import org.apache.logging.log4j.core.Filter;
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.appender.SocketAppender;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.apache.logging.log4j.core.net.ssl.KeyStoreConfiguration;
++import org.apache.logging.log4j.core.net.ssl.SslConfiguration;
++import org.apache.logging.log4j.core.net.ssl.StoreConfigurationException;
++import org.apache.logging.log4j.core.net.ssl.TestConstants;
++import org.apache.logging.log4j.core.net.ssl.TrustStoreConfiguration;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class SslXmlSocketServerTest extends AbstractSocketServerTest {
++
++ private static TcpSocketServer<InputStream> server;
++
++ private static SslConfiguration sslConfiguration;
++
++ private static void initServerSocketFactory() throws StoreConfigurationException {
++ final KeyStoreConfiguration ksc = new KeyStoreConfiguration(TestConstants.KEYSTORE_FILE,
++ TestConstants.KEYSTORE_PWD, TestConstants.KEYSTORE_TYPE, null);
++ final TrustStoreConfiguration tsc = new TrustStoreConfiguration(TestConstants.TRUSTSTORE_FILE,
++ TestConstants.TRUSTSTORE_PWD, null, null);
++ sslConfiguration = SslConfiguration.createSSLConfiguration(null, ksc, tsc);
++ }
++
++ @Override
++ protected SocketAppender createSocketAppender(final Filter socketFilter,
++ final Layout<? extends Serializable> socketLayout) {
++ // @formatter:off
++ return SocketAppender.newBuilder()
++ .withProtocol(this.protocol)
++ .withHost("localhost")
++ .withPort(this.port)
++ .withReconnectDelayMillis(-1)
++ .withName("test")
++ .withImmediateFlush(true)
++ .withImmediateFail(false)
++ .withIgnoreExceptions(false)
++ .withLayout(socketLayout)
++ .withFilter(socketFilter)
++ .withSslConfiguration(sslConfiguration)
++ .build();
++ // @formatter:on
++ }
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ initServerSocketFactory();
++ // Use a large buffer just to test the code, the UDP test uses a tiny buffer
++ server = new SecureTcpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(1024 * 100,
++ Charset.defaultCharset()), sslConfiguration);
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ try {
++ server.shutdown();
++ } catch (final IOException e) {
++ e.printStackTrace();
++ }
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public SslXmlSocketServerTest() {
++ super(Protocol.SSL, PORT, false);
++ }
++
++ @Override
++ protected Layout<String> createLayout() {
++ return super.createXmlLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpJsonSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/TcpJsonSocketServerTest.java
index 0000000,0000000..f12c908
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpJsonSocketServerTest.java
@@@ -1,0 -1,0 +1,62 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.InputStream;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class TcpJsonSocketServerTest extends AbstractSocketServerTest {
++
++ private static TcpSocketServer<InputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ server = TcpSocketServer.createJsonSocketServer(PORT_NUM);
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ try {
++ server.shutdown();
++ } catch (final IOException e) {
++ e.printStackTrace();
++ }
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public TcpJsonSocketServerTest() {
++ super(Protocol.TCP, PORT, false);
++ }
++
++ @Override
++ protected Layout<String> createLayout() {
++ return super.createJsonLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpSerializedSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/TcpSerializedSocketServerTest.java
index 0000000,0000000..275af20
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpSerializedSocketServerTest.java
@@@ -1,0 -1,0 +1,63 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.ObjectInputStream;
++import java.io.Serializable;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class TcpSerializedSocketServerTest extends AbstractSocketServerTest {
++
++ private static TcpSocketServer<ObjectInputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ server = TcpSocketServer.createSerializedSocketServer(PORT_NUM);
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ try {
++ server.shutdown();
++ } catch (final IOException e) {
++ e.printStackTrace();
++ }
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public TcpSerializedSocketServerTest() {
++ super(Protocol.TCP, PORT, false);
++ }
++
++ @Override
++ protected Layout<? extends Serializable> createLayout() {
++ return super.createSerializedLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpXmlSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/TcpXmlSocketServerTest.java
index 0000000,0000000..2b2cfd7
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/TcpXmlSocketServerTest.java
@@@ -1,0 -1,0 +1,65 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.InputStream;
++import java.nio.charset.Charset;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class TcpXmlSocketServerTest extends AbstractSocketServerTest {
++
++ private static TcpSocketServer<InputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ // Use a large buffer just to test the code, the UDP test uses a tiny buffer
++ server = new TcpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(1024 * 100,
++ Charset.defaultCharset()));
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ try {
++ server.shutdown();
++ } catch (final IOException e) {
++ e.printStackTrace();
++ }
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public TcpXmlSocketServerTest() {
++ super(Protocol.TCP, PORT, false);
++ }
++
++ @Override
++ protected Layout<String> createLayout() {
++ return super.createXmlLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadIdFilter.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadIdFilter.java
index 0000000,0000000..d98e3f4
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadIdFilter.java
@@@ -1,0 -1,0 +1,40 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++package org.apache.logging.log4j.server;
++
++import org.apache.logging.log4j.core.Filter;
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.filter.AbstractFilter;
++
++/**
++ * TODO Should use thread ID cache?
++ * @since 2.6
++ */
++public class ThreadIdFilter extends AbstractFilter {
++
++ private static final long serialVersionUID = 1L;
++
++ public ThreadIdFilter(final Result onMatch, final Result onMismatch) {
++ super(onMatch, onMismatch);
++ }
++
++ @Override
++ public Filter.Result filter(final LogEvent event) {
++ return event.getThreadId() == Thread.currentThread().getId() ? onMatch : onMismatch;
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadNameFilter.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadNameFilter.java
index 0000000,0000000..4204ac1
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadNameFilter.java
@@@ -1,0 -1,0 +1,39 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++package org.apache.logging.log4j.server;
++
++import org.apache.logging.log4j.core.Filter;
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.filter.AbstractFilter;
++
++/**
++ * TODO Should use thread name cache?
++ */
++public class ThreadNameFilter extends AbstractFilter {
++
++ private static final long serialVersionUID = 1L;
++
++ public ThreadNameFilter(final Result onMatch, final Result onMismatch) {
++ super(onMatch, onMismatch);
++ }
++
++ @Override
++ public Filter.Result filter(final LogEvent event) {
++ return event.getThreadName().equals(Thread.currentThread().getName()) ? onMatch : onMismatch;
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadPriorityFilter.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadPriorityFilter.java
index 0000000,0000000..6074f86
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/ThreadPriorityFilter.java
@@@ -1,0 -1,0 +1,40 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++package org.apache.logging.log4j.server;
++
++import org.apache.logging.log4j.core.Filter;
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.filter.AbstractFilter;
++
++/**
++ * TODO Should use thread priority cache?
++ * @since 2.6
++ */
++public class ThreadPriorityFilter extends AbstractFilter {
++
++ private static final long serialVersionUID = 1L;
++
++ public ThreadPriorityFilter(final Result onMatch, final Result onMismatch) {
++ super(onMatch, onMismatch);
++ }
++
++ @Override
++ public Filter.Result filter(final LogEvent event) {
++ return event.getThreadPriority() == Thread.currentThread().getPriority() ? onMatch : onMismatch;
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpJsonSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/UdpJsonSocketServerTest.java
index 0000000,0000000..7bd36f9
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpJsonSocketServerTest.java
@@@ -1,0 -1,0 +1,58 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.InputStream;
++import java.io.Serializable;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class UdpJsonSocketServerTest extends AbstractSocketServerTest {
++
++ private static UdpSocketServer<InputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ server = UdpSocketServer.createJsonSocketServer(PORT_NUM);
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ server.shutdown();
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public UdpJsonSocketServerTest() {
++ super(Protocol.UDP, PORT, true);
++ }
++
++ @Override
++ protected Layout<? extends Serializable> createLayout() {
++ return super.createJsonLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpSerializedSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/UdpSerializedSocketServerTest.java
index 0000000,0000000..9c806af
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpSerializedSocketServerTest.java
@@@ -1,0 -1,0 +1,60 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.ObjectInputStream;
++import java.io.Serializable;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++import org.junit.Ignore;
++
++@Ignore
++public class UdpSerializedSocketServerTest extends AbstractSocketServerTest {
++
++ private static UdpSocketServer<ObjectInputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ server = UdpSocketServer.createSerializedSocketServer(PORT_NUM);
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ server.shutdown();
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public UdpSerializedSocketServerTest() {
++ super(Protocol.UDP, PORT, true);
++ }
++
++ @Override
++ protected Layout<? extends Serializable> createLayout() {
++ return super.createSerializedLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpXmlSocketServerTest.java
----------------------------------------------------------------------
diff --cc log4j-server/src/test/java/org/apache/logging/log4j/server/UdpXmlSocketServerTest.java
index 0000000,0000000..0299312
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/test/java/org/apache/logging/log4j/server/UdpXmlSocketServerTest.java
@@@ -1,0 -1,0 +1,61 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.InputStream;
++import java.io.Serializable;
++import java.nio.charset.Charset;
++
++import org.apache.logging.log4j.core.Layout;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.net.Protocol;
++import org.junit.AfterClass;
++import org.junit.BeforeClass;
++
++public class UdpXmlSocketServerTest extends AbstractSocketServerTest {
++
++ private static UdpSocketServer<InputStream> server;
++
++ @BeforeClass
++ public static void setupClass() throws Exception {
++ (LoggerContext.getContext(false)).reconfigure();
++ // Use a tiny buffer just to test the code, the TCP test uses a large buffer
++ server = new UdpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(100,
++ Charset.defaultCharset()));
++ thread = server.startNewThread();
++ }
++
++ @AfterClass
++ public static void tearDownClass() {
++ server.shutdown();
++ try {
++ thread.join();
++ } catch (final InterruptedException e) {
++ // ignore
++ }
++ }
++
++ public UdpXmlSocketServerTest() {
++ super(Protocol.UDP, PORT, true);
++ }
++
++ @Override
++ protected Layout<? extends Serializable> createLayout() {
++ return super.createXmlLayout();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/resources/org/apache/logging/log4j/core/net/ssl/client.log4j2-keystore.jks
----------------------------------------------------------------------
diff --cc log4j-server/src/test/resources/org/apache/logging/log4j/core/net/ssl/client.log4j2-keystore.jks
index 0000000,0000000..36f11b6
new file mode 100644
Binary files differ
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/test/resources/org/apache/logging/log4j/core/net/ssl/truststore.jks
----------------------------------------------------------------------
diff --cc log4j-server/src/test/resources/org/apache/logging/log4j/core/net/ssl/truststore.jks
index 0000000,0000000..0e6aaf2
new file mode 100644
Binary files differ
[03/14] logging-log4j2 git commit: Move server components from core
to new server module
Posted by mi...@apache.org.
Move server components from core to new server module
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f515fa3c
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f515fa3c
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f515fa3c
Branch: refs/heads/master
Commit: f515fa3c4ab8ecca83f75bcb29ceb71b54c61bc4
Parents: 67c18b0
Author: Mikael St�ldal <mi...@magine.com>
Authored: Fri Mar 17 14:42:19 2017 +0100
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Fri Mar 17 14:43:19 2017 +0100
----------------------------------------------------------------------
.../core/net/mom/jms/AbstractJmsReceiver.java | 48 ---
.../core/net/mom/jms/JmsQueueReceiver.java | 46 ---
.../core/net/mom/jms/JmsTopicReceiver.java | 46 ---
.../log4j/core/net/mom/jms/package-info.java | 26 --
.../core/net/server/AbstractLogEventBridge.java | 44 ---
.../core/net/server/AbstractSocketServer.java | 209 ------------
.../net/server/InputStreamLogEventBridge.java | 103 ------
.../log4j/core/net/server/JmsServer.java | 148 ---------
.../server/JsonInputStreamLogEventBridge.java | 90 ------
.../log4j/core/net/server/LogEventBridge.java | 57 ----
.../server/ObjectInputStreamLogEventBridge.java | 45 ---
.../core/net/server/SecureTcpSocketServer.java | 37 ---
.../log4j/core/net/server/TcpSocketServer.java | 314 -------------------
.../log4j/core/net/server/UdpSocketServer.java | 169 ----------
.../server/XmlInputStreamLogEventBridge.java | 54 ----
.../log4j/core/net/server/package-info.java | 24 --
.../net/server/AbstractSocketServerTest.java | 237 --------------
.../core/net/server/SslXmlSocketServerTest.java | 104 ------
.../net/server/TcpJsonSocketServerTest.java | 62 ----
.../server/TcpSerializedSocketServerTest.java | 63 ----
.../core/net/server/TcpXmlSocketServerTest.java | 65 ----
.../log4j/core/net/server/ThreadIdFilter.java | 40 ---
.../log4j/core/net/server/ThreadNameFilter.java | 39 ---
.../core/net/server/ThreadPriorityFilter.java | 40 ---
.../net/server/UdpJsonSocketServerTest.java | 58 ----
.../server/UdpSerializedSocketServerTest.java | 60 ----
.../core/net/server/UdpXmlSocketServerTest.java | 61 ----
log4j-server/pom.xml | 197 ++++++++++++
.../core/net/mom/jms/AbstractJmsReceiver.java | 48 +++
.../core/net/mom/jms/JmsQueueReceiver.java | 46 +++
.../core/net/mom/jms/JmsTopicReceiver.java | 46 +++
.../log4j/core/net/mom/jms/package-info.java | 26 ++
.../core/net/server/AbstractLogEventBridge.java | 44 +++
.../core/net/server/AbstractSocketServer.java | 209 ++++++++++++
.../net/server/InputStreamLogEventBridge.java | 103 ++++++
.../log4j/core/net/server/JmsServer.java | 148 +++++++++
.../server/JsonInputStreamLogEventBridge.java | 90 ++++++
.../log4j/core/net/server/LogEventBridge.java | 57 ++++
.../server/ObjectInputStreamLogEventBridge.java | 45 +++
.../core/net/server/SecureTcpSocketServer.java | 37 +++
.../log4j/core/net/server/TcpSocketServer.java | 314 +++++++++++++++++++
.../log4j/core/net/server/UdpSocketServer.java | 169 ++++++++++
.../server/XmlInputStreamLogEventBridge.java | 54 ++++
.../log4j/core/net/server/package-info.java | 24 ++
log4j-server/src/site/markdown/index.md | 29 ++
log4j-server/src/site/site.xml | 52 +++
.../net/server/AbstractSocketServerTest.java | 237 ++++++++++++++
.../core/net/server/SslXmlSocketServerTest.java | 104 ++++++
.../net/server/TcpJsonSocketServerTest.java | 62 ++++
.../server/TcpSerializedSocketServerTest.java | 63 ++++
.../core/net/server/TcpXmlSocketServerTest.java | 65 ++++
.../log4j/core/net/server/ThreadIdFilter.java | 40 +++
.../log4j/core/net/server/ThreadNameFilter.java | 39 +++
.../core/net/server/ThreadPriorityFilter.java | 40 +++
.../net/server/UdpJsonSocketServerTest.java | 58 ++++
.../server/UdpSerializedSocketServerTest.java | 60 ++++
.../core/net/server/UdpXmlSocketServerTest.java | 61 ++++
pom.xml | 6 +
58 files changed, 2573 insertions(+), 2289 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/AbstractJmsReceiver.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/AbstractJmsReceiver.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/AbstractJmsReceiver.java
deleted file mode 100644
index 753fc80..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/AbstractJmsReceiver.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.net.mom.jms;
-
-import org.apache.logging.log4j.core.net.server.JmsServer;
-
-/**
- * Common JMS server functionality.
- *
- * @since 2.6
- */
-public abstract class AbstractJmsReceiver {
-
- /**
- * Prints out usage information to {@linkplain System#err standard error}.
- */
- protected abstract void usage();
-
- /**
- * Executes a JmsServer with the given command line arguments.
- *
- * @param args command line arguments
- * @throws Exception
- */
- protected void doMain(final String... args) throws Exception {
- if (args.length != 4) {
- usage();
- System.exit(1);
- }
- final JmsServer server = new JmsServer(args[0], args[1], args[2], args[3]);
- server.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsQueueReceiver.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsQueueReceiver.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsQueueReceiver.java
deleted file mode 100644
index dac46d3..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsQueueReceiver.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.net.mom.jms;
-
-/**
- * Receives Log Events over a JMS Queue. This implementation expects that all messages will
- * contain a serialized LogEvent.
- */
-public class JmsQueueReceiver extends AbstractJmsReceiver {
-
- private JmsQueueReceiver() {
- }
-
- /**
- * Main startup for the receiver.
- *
- * @param args The command line arguments.
- * @throws Exception if an error occurs.
- */
- public static void main(final String[] args) throws Exception {
- final JmsQueueReceiver receiver = new JmsQueueReceiver();
- receiver.doMain(args);
- }
-
- @Override
- protected void usage() {
- System.err.println("Wrong number of arguments.");
- System.err.println("Usage: java " + JmsQueueReceiver.class.getName()
- + " QueueConnectionFactoryBindingName QueueBindingName username password");
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsTopicReceiver.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsTopicReceiver.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsTopicReceiver.java
deleted file mode 100644
index 4442ab1..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/JmsTopicReceiver.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.net.mom.jms;
-
-/**
- * Receives Topic messages that contain LogEvents. This implementation expects that all messages
- * are serialized log events.
- */
-public class JmsTopicReceiver extends AbstractJmsReceiver {
-
- private JmsTopicReceiver() {
- }
-
- /**
- * Main startup for the receiver.
- *
- * @param args The command line arguments.
- * @throws Exception if an error occurs.
- */
- public static void main(final String[] args) throws Exception {
- final JmsTopicReceiver receiver = new JmsTopicReceiver();
- receiver.doMain(args);
- }
-
- @Override
- protected void usage() {
- System.err.println("Wrong number of arguments.");
- System.err.println("Usage: java " + JmsTopicReceiver.class.getName()
- + " TopicConnectionFactoryBindingName TopicBindingName username password");
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/package-info.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/package-info.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/package-info.java
deleted file mode 100644
index 9c3e03e..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/mom/jms/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-/**
- * Supporting network code for JMS appenders.
- *
- * <p>Note that you can use JmsQueueReceiver or JmsTopicReceiver as executable main classes to receive log events over
- * JMS (sent via the appropriate JMS appender) that can be subsequently logged according to the configuration given to
- * the running process. Of course, use of these classes as standalone executables are entirely optional and can
- * be used directly in your application (e.g., through your Spring {@code beans.xml} configuration).</p>
- */
-package org.apache.logging.log4j.core.net.mom.jms;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractLogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractLogEventBridge.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractLogEventBridge.java
deleted file mode 100644
index 59b889b..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractLogEventBridge.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Abstract class for implementations of {@link LogEventBridge}.
- *
- * @param <T>
- * The kind of input stream read
- */
-public abstract class AbstractLogEventBridge<T extends InputStream> implements LogEventBridge<T> {
-
- protected static final int END = -1;
-
- protected static final Logger logger = StatusLogger.getLogger();
-
- // The default is to return the same object as given.
- @SuppressWarnings("unchecked")
- @Override
- public T wrapStream(final InputStream inputStream) throws IOException {
- return (T) inputStream;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
deleted file mode 100644
index 9836694..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/AbstractSocketServer.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.InetAddress;
-import java.net.URI;
-import java.net.URL;
-import java.util.Objects;
-
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.validators.PositiveInteger;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEventListener;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
-import org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory;
-import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
-import org.apache.logging.log4j.core.util.InetAddressConverter;
-import org.apache.logging.log4j.core.util.Log4jThread;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Abstract socket server for TCP and UDP implementations.
- *
- * @param <T>
- * The kind of input stream read
- *
- * TODO Make a LifeCycle
- */
-public abstract class AbstractSocketServer<T extends InputStream> extends LogEventListener implements Runnable {
-
- protected static class CommandLineArguments extends BasicCommandLineArguments {
-
- @Parameter(names = { "--config", "-c" }, description = "Log4j configuration file location (path or URL).")
- private String configLocation;
-
- @Parameter(names = { "--interactive",
- "-i" }, description = "Accepts commands on standard input (\"exit\" is the only command).")
- private boolean interactive;
-
- @Parameter(names = { "--port",
- "-p" }, validateWith = PositiveInteger.class, description = "Server socket port.")
- private int port;
-
- @Parameter(names = { "--localbindaddress",
- "-a" }, converter = InetAddressConverter.class, description = "Server socket local bind address.")
- private InetAddress localBindAddress;
-
- String getConfigLocation() {
- return configLocation;
- }
-
- int getPort() {
- return port;
- }
-
- protected boolean isInteractive() {
- return interactive;
- }
-
- void setConfigLocation(final String configLocation) {
- this.configLocation = configLocation;
- }
-
- void setInteractive(final boolean interactive) {
- this.interactive = interactive;
- }
-
- void setPort(final int port) {
- this.port = port;
- }
-
- InetAddress getLocalBindAddress() {
- return localBindAddress;
- }
-
- void setLocalBindAddress(final InetAddress localBindAddress) {
- this.localBindAddress = localBindAddress;
- }
- }
-
- /**
- * Factory that creates a Configuration for the server.
- */
- protected static class ServerConfigurationFactory extends XmlConfigurationFactory {
-
- private final String path;
-
- public ServerConfigurationFactory(final String path) {
- this.path = path;
- }
-
- @Override
- public Configuration getConfiguration(final LoggerContext loggerContext, final String name,
- final URI configLocation) {
- if (Strings.isNotEmpty(path)) {
- File file = null;
- ConfigurationSource source = null;
- try {
- file = new File(path);
- final FileInputStream is = new FileInputStream(file);
- source = new ConfigurationSource(is, file);
- } catch (final FileNotFoundException ignored) {
- // Ignore this error
- }
- if (source == null) {
- try {
- final URL url = new URL(path);
- source = new ConfigurationSource(url.openStream(), url);
- } catch (final IOException ignored) {
- // Ignore this error
- }
- }
-
- try {
- if (source != null) {
- return new XmlConfiguration(loggerContext, source);
- }
- } catch (final Exception ignored) {
- // Ignore this error.
- }
- System.err.println("Unable to process configuration at " + path + ", using default.");
- }
- return super.getConfiguration(loggerContext, name, configLocation);
- }
- }
-
- protected static final int MAX_PORT = 65534;
-
- private volatile boolean active = true;
-
- protected final LogEventBridge<T> logEventInput;
-
- protected final Logger logger;
-
- /**
- * Creates a new socket server.
- *
- * @param port
- * listen to this port
- * @param logEventInput
- * Use this input to read log events.
- */
- public AbstractSocketServer(final int port, final LogEventBridge<T> logEventInput) {
- this.logger = LogManager.getLogger(this.getClass().getName() + '.' + port);
- this.logEventInput = Objects.requireNonNull(logEventInput, "LogEventInput");
- }
-
- protected boolean isActive() {
- return this.active;
- }
-
- protected void setActive(final boolean isActive) {
- this.active = isActive;
- }
-
- /**
- * Start this server in a new thread.
- *
- * @return the new thread that running this server.
- */
- public Thread startNewThread() {
- final Thread thread = new Log4jThread(this);
- thread.start();
- return thread;
- }
-
- public abstract void shutdown() throws Exception;
-
- public void awaitTermination(final Thread serverThread) throws Exception {
- final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- while (true) {
- final String line = reader.readLine();
- if (line == null
- || line.equalsIgnoreCase("quit")
- || line.equalsIgnoreCase("stop")
- || line.equalsIgnoreCase("exit")) {
- this.shutdown();
- serverThread.join();
- break;
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/InputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/InputStreamLogEventBridge.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/InputStreamLogEventBridge.java
deleted file mode 100644
index 11b4aa4..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/InputStreamLogEventBridge.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LogEventListener;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.util.Strings;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-
-/**
- * Reads and logs {@link LogEvent}s from an {@link InputStream}.
- */
-public abstract class InputStreamLogEventBridge extends AbstractLogEventBridge<InputStream> {
-
- private final int bufferSize;
-
- private final Charset charset;
-
- private final String eventEndMarker;
-
- private final ObjectReader objectReader;
-
- public InputStreamLogEventBridge(final ObjectMapper mapper, final int bufferSize, final Charset charset, final String eventEndMarker) {
- this.bufferSize = bufferSize;
- this.charset = charset;
- this.eventEndMarker = eventEndMarker;
- this.objectReader = mapper.readerFor(Log4jLogEvent.class);
- }
-
- abstract protected int[] getEventIndices(final String text, int beginIndex);
-
- @Override
- public void logEvents(final InputStream inputStream, final LogEventListener logEventListener) throws IOException {
- String workingText = Strings.EMPTY;
- try {
- // Allocate buffer once
- final byte[] buffer = new byte[bufferSize];
- String textRemains = workingText = Strings.EMPTY;
- while (true) {
- // Process until the stream is EOF.
- final int streamReadLength = inputStream.read(buffer);
- if (streamReadLength == END) {
- // The input stream is EOF
- break;
- }
- final String text = workingText = textRemains + new String(buffer, 0, streamReadLength, charset);
- int beginIndex = 0;
- while (true) {
- // Extract and log all XML events in the buffer
- final int[] pair = getEventIndices(text, beginIndex);
- final int eventStartMarkerIndex = pair[0];
- if (eventStartMarkerIndex < 0) {
- // No more events or partial XML only in the buffer.
- // Save the unprocessed string part
- textRemains = text.substring(beginIndex);
- break;
- }
- final int eventEndMarkerIndex = pair[1];
- if (eventEndMarkerIndex > 0) {
- final int eventEndXmlIndex = eventEndMarkerIndex + eventEndMarker.length();
- final String textEvent = workingText = text.substring(eventStartMarkerIndex, eventEndXmlIndex);
- final LogEvent logEvent = unmarshal(textEvent);
- logEventListener.log(logEvent);
- beginIndex = eventEndXmlIndex;
- } else {
- // No more events or partial XML only in the buffer.
- // Save the unprocessed string part
- textRemains = text.substring(beginIndex);
- break;
- }
- }
- }
- } catch (final IOException ex) {
- logger.error(workingText, ex);
- }
- }
-
- protected Log4jLogEvent unmarshal(final String jsonEvent) throws IOException {
- return this.objectReader.readValue(jsonEvent);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
deleted file mode 100644
index bcbba40..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.Charset;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.ObjectMessage;
-
-import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.core.AbstractLifeCycle;
-import org.apache.logging.log4j.core.LifeCycle2;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LogEventListener;
-import org.apache.logging.log4j.core.appender.mom.JmsManager;
-import org.apache.logging.log4j.core.net.JndiManager;
-
-/**
- * LogEventListener server that receives LogEvents over a JMS {@link javax.jms.Destination}.
- *
- * @since 2.1
- */
-public class JmsServer extends LogEventListener implements MessageListener, LifeCycle2 {
-
- private final AtomicReference<State> state = new AtomicReference<>(State.INITIALIZED);
- private final JmsManager jmsManager;
- private MessageConsumer messageConsumer;
-
- public JmsServer(final String connectionFactoryBindingName,
- final String destinationBindingName,
- final String username,
- final String password) {
- final String managerName = JmsServer.class.getName() + '@' + JmsServer.class.hashCode();
- final JndiManager jndiManager = JndiManager.getDefaultManager(managerName);
- jmsManager = JmsManager.getJmsManager(managerName, jndiManager, connectionFactoryBindingName,
- destinationBindingName, username, password);
- }
-
- @Override
- public State getState() {
- return state.get();
- }
-
- @Override
- public void onMessage(final Message message) {
- try {
- if (message instanceof ObjectMessage) {
- final Object body = ((ObjectMessage) message).getObject();
- if (body instanceof LogEvent) {
- log((LogEvent) body);
- } else {
- LOGGER.warn("Expected ObjectMessage to contain LogEvent. Got type {} instead.", body.getClass());
- }
- } else {
- LOGGER.warn("Received message of type {} and JMSType {} which cannot be handled.", message.getClass(),
- message.getJMSType());
- }
- } catch (final JMSException e) {
- LOGGER.catching(e);
- }
- }
-
- @Override
- public void initialize() {
- }
-
- @Override
- public void start() {
- if (state.compareAndSet(State.INITIALIZED, State.STARTING)) {
- try {
- messageConsumer = jmsManager.createMessageConsumer();
- messageConsumer.setMessageListener(this);
- } catch (final JMSException e) {
- throw new LoggingException(e);
- }
- }
- }
-
- @Override
- public void stop() {
- stop(AbstractLifeCycle.DEFAULT_STOP_TIMEOUT, AbstractLifeCycle.DEFAULT_STOP_TIMEUNIT);
- }
-
- @Override
- public boolean stop(final long timeout, final TimeUnit timeUnit) {
- boolean stopped = true;
- try {
- messageConsumer.close();
- } catch (final JMSException e) {
- LOGGER.debug("Exception closing {}", messageConsumer, e);
- stopped = false;
- }
- return stopped && jmsManager.stop(timeout, timeUnit);
- }
-
- @Override
- public boolean isStarted() {
- return state.get() == State.STARTED;
- }
-
- @Override
- public boolean isStopped() {
- return state.get() == State.STOPPED;
- }
-
- /**
- * Starts and runs this server until the user types "exit" into standard input.
- *
- * @throws IOException
- * @since 2.6
- */
- public void run() throws IOException {
- this.start();
- System.out.println("Type \"exit\" to quit.");
- final BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in, Charset.defaultCharset()));
- while (true) {
- final String line = stdin.readLine();
- if (line == null || line.equalsIgnoreCase("exit")) {
- System.out.println("Exiting. Kill the application if it does not exit due to daemon threads.");
- this.stop();
- return;
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JsonInputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JsonInputStreamLogEventBridge.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JsonInputStreamLogEventBridge.java
deleted file mode 100644
index a0e4fdb..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JsonInputStreamLogEventBridge.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.jackson.Log4jJsonObjectMapper;
-import org.apache.logging.log4j.util.Chars;
-
-/**
- * Reads and logs JSON {@link LogEvent}s from an {@link InputStream}..
- */
-public class JsonInputStreamLogEventBridge extends InputStreamLogEventBridge {
-
- private static final int[] END_PAIR = new int[] { END, END };
- private static final char EVENT_END_MARKER = '}';
- private static final char EVENT_START_MARKER = '{';
- private static final char JSON_ESC = '\\';
- private static final char JSON_STR_DELIM = Chars.DQUOTE;
- private static final boolean THREAD_CONTEXT_MAP_AS_LIST = false;
-
- public JsonInputStreamLogEventBridge() {
- this(1024, Charset.defaultCharset());
- }
-
- public JsonInputStreamLogEventBridge(final int bufferSize, final Charset charset) {
- super(new Log4jJsonObjectMapper(THREAD_CONTEXT_MAP_AS_LIST, true), bufferSize, charset,
- String.valueOf(EVENT_END_MARKER));
- }
-
- @Override
- protected int[] getEventIndices(final String text, final int beginIndex) {
- // Scan the text for the end of the next JSON object.
- final int start = text.indexOf(EVENT_START_MARKER, beginIndex);
- if (start == END) {
- return END_PAIR;
- }
- final char[] charArray = text.toCharArray();
- int stack = 0;
- boolean inStr = false;
- boolean inEsc = false;
- for (int i = start; i < charArray.length; i++) {
- final char c = charArray[i];
- if (inEsc) {
- // Skip this char and continue
- inEsc = false;
- } else {
- switch (c) {
- case EVENT_START_MARKER:
- if (!inStr) {
- stack++;
- }
- break;
- case EVENT_END_MARKER:
- if (!inStr) {
- stack--;
- }
- break;
- case JSON_STR_DELIM:
- inStr = !inStr;
- break;
- case JSON_ESC:
- inEsc = true;
- break;
- }
- if (stack == 0) {
- return new int[] { start, i };
- }
- }
- }
- return END_PAIR;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/LogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/LogEventBridge.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/LogEventBridge.java
deleted file mode 100644
index ba45bb6..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/LogEventBridge.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LogEventListener;
-
-/**
- * Reads {@link LogEvent}s from the given input stream and logs them as they are discovered on the given logger.
- *
- * <p>
- * Should be stateless.
- * </p>
- *
- * @param <T>
- * The kind of {@link InputStream} to wrap and read.
- */
-public interface LogEventBridge<T extends InputStream> {
-
- /**
- * Reads {@link LogEvent}s from the given input stream and logs them as they are discovered on the given logger.
- *
- * @param inputStream
- * the input stream to read
- * @param logEventListener
- * TODO
- * @throws IOException
- */
- void logEvents(T inputStream, LogEventListener logEventListener) throws IOException;
-
- /**
- * Wraps the given stream if needed.
- *
- * @param inputStream
- * the stream to wrap
- * @return the wrapped stream or the given stream.
- * @throws IOException
- */
- T wrapStream(InputStream inputStream) throws IOException;
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/ObjectInputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/ObjectInputStreamLogEventBridge.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/ObjectInputStreamLogEventBridge.java
deleted file mode 100644
index 059f069..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/ObjectInputStreamLogEventBridge.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LogEventListener;
-
-/**
- * Reads and logs serialized {@link LogEvent} objects from an {@link ObjectInputStream}.
- */
-public class ObjectInputStreamLogEventBridge extends AbstractLogEventBridge<ObjectInputStream> {
-
- @Override
- public void logEvents(final ObjectInputStream inputStream, final LogEventListener logEventListener)
- throws IOException {
- try {
- logEventListener.log((LogEvent) inputStream.readObject());
- } catch (final ClassNotFoundException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public ObjectInputStream wrapStream(final InputStream inputStream) throws IOException {
- return new ObjectInputStream(inputStream);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/SecureTcpSocketServer.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/SecureTcpSocketServer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/SecureTcpSocketServer.java
deleted file mode 100644
index 87390e8..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/SecureTcpSocketServer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.logging.log4j.core.net.ssl.SslConfiguration;
-
-/**
- * Listens for events over a secure socket connection (SSL/TLS).
- *
- * @param <T>
- * The kind of input stream read
- */
-public class SecureTcpSocketServer<T extends InputStream> extends TcpSocketServer<T> {
-
- public SecureTcpSocketServer(final int port, final LogEventBridge<T> logEventInput,
- final SslConfiguration sslConfig) throws IOException {
- super(port, logEventInput, sslConfig.getSslServerSocketFactory().createServerSocket(port));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/TcpSocketServer.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/TcpSocketServer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/TcpSocketServer.java
deleted file mode 100644
index 68ac1ba..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/TcpSocketServer.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.OptionalDataException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.validators.PositiveInteger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
-import org.apache.logging.log4j.core.util.Closer;
-import org.apache.logging.log4j.core.util.Log4jThread;
-import org.apache.logging.log4j.message.EntryMessage;
-
-/**
- * Listens for Log4j events on a TCP server socket and passes them on to Log4j.
- *
- * @param <T>
- * The kind of input stream read
- * @see #main(String[])
- */
-public class TcpSocketServer<T extends InputStream> extends AbstractSocketServer<T> {
-
- protected static class CommandLineArguments extends AbstractSocketServer.CommandLineArguments {
-
- @Parameter(names = { "--backlog",
- "-b" }, validateWith = PositiveInteger.class, description = "Server socket backlog.")
- // Same default as ServerSocket
- private int backlog = 50;
-
- int getBacklog() {
- return backlog;
- }
-
- void setBacklog(final int backlog) {
- this.backlog = backlog;
- }
-
- }
-
- /**
- * Thread that processes the events.
- */
- private class SocketHandler extends Log4jThread {
-
- private final T inputStream;
-
- private volatile boolean shutdown = false;
-
- public SocketHandler(final Socket socket) throws IOException {
- this.inputStream = logEventInput.wrapStream(socket.getInputStream());
- }
-
- @Override
- public void run() {
- final EntryMessage entry = logger.traceEntry();
- boolean closed = false;
- try {
- try {
- while (!shutdown) {
- logEventInput.logEvents(inputStream, TcpSocketServer.this);
- }
- } catch (final EOFException e) {
- closed = true;
- } catch (final OptionalDataException e) {
- logger.error("OptionalDataException eof=" + e.eof + " length=" + e.length, e);
- } catch (final IOException e) {
- logger.error("IOException encountered while reading from socket", e);
- }
- if (!closed) {
- Closer.closeSilently(inputStream);
- }
- } finally {
- handlers.remove(Long.valueOf(getId()));
- }
- logger.traceExit(entry);
- }
-
- public void shutdown() {
- this.shutdown = true;
- interrupt();
- }
- }
-
- /**
- * Creates a socket server that reads JSON log events.
- *
- * @param port
- * the port to listen
- * @return a new a socket server
- * @throws IOException
- * if an I/O error occurs when opening the socket.
- */
- public static TcpSocketServer<InputStream> createJsonSocketServer(final int port) throws IOException {
- LOGGER.entry("createJsonSocketServer", port);
- final TcpSocketServer<InputStream> socketServer = new TcpSocketServer<>(port, new JsonInputStreamLogEventBridge());
- return LOGGER.exit(socketServer);
- }
-
- /**
- * Creates a socket server that reads serialized log events.
- *
- * @param port
- * the port to listen
- * @return a new a socket server
- * @throws IOException
- * if an I/O error occurs when opening the socket.
- */
- public static TcpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port) throws IOException {
- LOGGER.entry(port);
- final TcpSocketServer<ObjectInputStream> socketServer = new TcpSocketServer<>(port, new ObjectInputStreamLogEventBridge());
- return LOGGER.exit(socketServer);
- }
-
- /**
- * Creates a socket server that reads serialized log events.
- *
- * @param port the port to listen
- * @param localBindAddress The server socket's local bin address
- * @return a new a socket server
- * @throws IOException
- * if an I/O error occurs when opening the socket.
- * @since 2.7
- */
- public static TcpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port, final int backlog,
- final InetAddress localBindAddress) throws IOException {
- LOGGER.entry(port);
- final TcpSocketServer<ObjectInputStream> socketServer = new TcpSocketServer<>(port, backlog, localBindAddress,
- new ObjectInputStreamLogEventBridge());
- return LOGGER.exit(socketServer);
- }
-
- /**
- * Creates a socket server that reads XML log events.
- *
- * @param port
- * the port to listen
- * @return a new a socket server
- * @throws IOException
- * if an I/O error occurs when opening the socket.
- */
- public static TcpSocketServer<InputStream> createXmlSocketServer(final int port) throws IOException {
- LOGGER.entry(port);
- final TcpSocketServer<InputStream> socketServer = new TcpSocketServer<>(port, new XmlInputStreamLogEventBridge());
- return LOGGER.exit(socketServer);
- }
-
- /**
- * Main startup for the server. Run with "--help" for to print command line help on the console.
- *
- * @param args
- * The command line arguments.
- * @throws Exception
- * if an error occurs.
- */
- public static void main(final String[] args) throws Exception {
- final CommandLineArguments cla = BasicCommandLineArguments.parseCommandLine(args, TcpSocketServer.class, new CommandLineArguments());
- if (cla.isHelp()) {
- return;
- }
- if (cla.getConfigLocation() != null) {
- ConfigurationFactory.setConfigurationFactory(new ServerConfigurationFactory(cla.getConfigLocation()));
- }
- final TcpSocketServer<ObjectInputStream> socketServer = TcpSocketServer
- .createSerializedSocketServer(cla.getPort(), cla.getBacklog(), cla.getLocalBindAddress());
- final Thread serverThread = socketServer.startNewThread();
- if (cla.isInteractive()) {
- socketServer.awaitTermination(serverThread);
- }
- }
-
- private final ConcurrentMap<Long, SocketHandler> handlers = new ConcurrentHashMap<>();
-
- private final ServerSocket serverSocket;
-
- /**
- * Constructor.
- *
- * @param port
- * The server socket port.
- * @param backlog
- * The server socket backlog.
- * @param localBindAddress TODO
- * @param logEventInput
- * the log even input
- * @throws IOException
- * if an I/O error occurs when opening the socket.
- * @since 2.7
- */
- @SuppressWarnings("resource")
- public TcpSocketServer(final int port, final int backlog, final InetAddress localBindAddress, final LogEventBridge<T> logEventInput) throws IOException {
- this(port, logEventInput, new ServerSocket(port, backlog, localBindAddress));
- }
-
- /**
- * Constructor.
- *
- * @param port
- * to listen.
- * @param logEventInput
- * the log even input
- * @throws IOException
- * if an I/O error occurs when opening the socket.
- */
- public TcpSocketServer(final int port, final LogEventBridge<T> logEventInput) throws IOException {
- this(port, logEventInput, extracted(port));
- }
-
- private static ServerSocket extracted(final int port) throws IOException {
- return new ServerSocket(port);
- }
-
- /**
- * Constructor.
- *
- * @param port
- * to listen.
- * @param logEventInput
- * the log even input
- * @param serverSocket
- * the socket server
- * @throws IOException
- * if an I/O error occurs when opening the socket.
- */
- public TcpSocketServer(final int port, final LogEventBridge<T> logEventInput, final ServerSocket serverSocket)
- throws IOException {
- super(port, logEventInput);
- this.serverSocket = serverSocket;
- }
-
- /**
- * Accept incoming events and processes them.
- */
- @Override
- public void run() {
- final EntryMessage entry = logger.traceEntry();
- while (isActive()) {
- if (serverSocket.isClosed()) {
- return;
- }
- try {
- // Accept incoming connections.
- logger.debug("Listening for a connection {}...", serverSocket);
- final Socket clientSocket = serverSocket.accept();
- logger.debug("Acepted connection on {}...", serverSocket);
- logger.debug("Socket accepted: {}", clientSocket);
- clientSocket.setSoLinger(true, 0);
-
- // accept() will block until a client connects to the server.
- // If execution reaches this point, then it means that a client
- // socket has been accepted.
-
- final SocketHandler handler = new SocketHandler(clientSocket);
- handlers.put(Long.valueOf(handler.getId()), handler);
- handler.start();
- } catch (final IOException e) {
- if (serverSocket.isClosed()) {
- // OK we're done.
- logger.traceExit(entry);
- return;
- }
- logger.error("Exception encountered on accept. Ignoring. Stack trace :", e);
- }
- }
- for (final Map.Entry<Long, SocketHandler> handlerEntry : handlers.entrySet()) {
- final SocketHandler handler = handlerEntry.getValue();
- handler.shutdown();
- try {
- handler.join();
- } catch (final InterruptedException ignored) {
- // Ignore the exception
- }
- }
- logger.traceExit(entry);
- }
-
- /**
- * Shutdown the server.
- *
- * @throws IOException if the server socket could not be closed
- */
- @Override
- public void shutdown() throws IOException {
- final EntryMessage entry = logger.traceEntry();
- setActive(false);
- Thread.currentThread().interrupt();
- serverSocket.close();
- logger.traceExit(entry);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/UdpSocketServer.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/UdpSocketServer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/UdpSocketServer.java
deleted file mode 100644
index ed04f69..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/UdpSocketServer.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.ByteArrayInputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.OptionalDataException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
-
-/**
- * Listens for Log4j events on a datagram socket and passes them on to Log4j.
- *
- * @param <T>
- * The kind of input stream read
- * @see #main(String[])
- */
-public class UdpSocketServer<T extends InputStream> extends AbstractSocketServer<T> {
-
- /**
- * Creates a socket server that reads JSON log events.
- *
- * @param port
- * the port to listen
- * @return a new a socket server
- * @throws IOException
- * if an I/O error occurs when opening the socket.
- */
- public static UdpSocketServer<InputStream> createJsonSocketServer(final int port) throws IOException {
- return new UdpSocketServer<>(port, new JsonInputStreamLogEventBridge());
- }
-
- /**
- * Creates a socket server that reads serialized log events.
- *
- * @param port
- * the port to listen
- * @return a new a socket server
- * @throws IOException
- * if an I/O error occurs when opening the socket.
- */
- public static UdpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port) throws IOException {
- return new UdpSocketServer<>(port, new ObjectInputStreamLogEventBridge());
- }
-
- /**
- * Creates a socket server that reads XML log events.
- *
- * @param port
- * the port to listen
- * @return a new a socket server
- * @throws IOException
- * if an I/O error occurs when opening the socket.
- */
- public static UdpSocketServer<InputStream> createXmlSocketServer(final int port) throws IOException {
- return new UdpSocketServer<>(port, new XmlInputStreamLogEventBridge());
- }
-
- /**
- * Main startup for the server. Run with "--help" for to print command line help on the console.
- *
- * @param args
- * The command line arguments.
- * @throws Exception
- * if an error occurs.
- */
- public static void main(final String[] args) throws Exception {
- final CommandLineArguments cla = BasicCommandLineArguments.parseCommandLine(args, UdpSocketServer.class, new CommandLineArguments());
- if (cla.isHelp()) {
- return;
- }
- if (cla.getConfigLocation() != null) {
- ConfigurationFactory.setConfigurationFactory(new ServerConfigurationFactory(cla.getConfigLocation()));
- }
- final UdpSocketServer<ObjectInputStream> socketServer = UdpSocketServer
- .createSerializedSocketServer(cla.getPort());
- final Thread serverThread = socketServer.startNewThread();
- if (cla.isInteractive()) {
- socketServer.awaitTermination(serverThread);
- }
- }
-
- private final DatagramSocket datagramSocket;
-
- // max size so we only have to deal with one packet
- private final int maxBufferSize = 1024 * 65 + 1024;
-
- /**
- * Constructor.
- *
- * @param port
- * to listen on.
- * @param logEventInput
- * @throws IOException
- * If an error occurs.
- */
- public UdpSocketServer(final int port, final LogEventBridge<T> logEventInput) throws IOException {
- super(port, logEventInput);
- this.datagramSocket = new DatagramSocket(port);
- }
-
- /**
- * Accept incoming events and processes them.
- */
- @Override
- public void run() {
- while (isActive()) {
- if (datagramSocket.isClosed()) {
- // OK we're done.
- return;
- }
- try {
- final byte[] buf = new byte[maxBufferSize];
- final DatagramPacket packet = new DatagramPacket(buf, buf.length);
- datagramSocket.receive(packet);
- final ByteArrayInputStream bais = new ByteArrayInputStream(packet.getData(), packet.getOffset(), packet.getLength());
- logEventInput.logEvents(logEventInput.wrapStream(bais), this);
- } catch (final OptionalDataException e) {
- if (datagramSocket.isClosed()) {
- // OK we're done.
- return;
- }
- logger.error("OptionalDataException eof=" + e.eof + " length=" + e.length, e);
- } catch (final EOFException e) {
- if (datagramSocket.isClosed()) {
- // OK we're done.
- return;
- }
- logger.info("EOF encountered");
- } catch (final IOException e) {
- if (datagramSocket.isClosed()) {
- // OK we're done.
- return;
- }
- logger.error("Exception encountered on accept. Ignoring. Stack Trace :", e);
- }
- }
- }
-
- /**
- * Shutdown the server.
- */
- @Override
- public void shutdown() {
- this.setActive(false);
- Thread.currentThread().interrupt();
- datagramSocket.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/XmlInputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/XmlInputStreamLogEventBridge.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/XmlInputStreamLogEventBridge.java
deleted file mode 100644
index 7853398..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/XmlInputStreamLogEventBridge.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.jackson.Log4jXmlObjectMapper;
-
-/**
- * Reads and logs {@link LogEvent}s from an {@link InputStream}.
- */
-public class XmlInputStreamLogEventBridge extends InputStreamLogEventBridge {
-
- private static final String EVENT_END = "</Event>";
- private static final String EVENT_START_NS_N = "<Event>";
- private static final String EVENT_START_NS_Y = "<Event ";
-
- public XmlInputStreamLogEventBridge() {
- this(1024, Charset.defaultCharset());
- }
-
- public XmlInputStreamLogEventBridge(final int bufferSize, final Charset charset) {
- super(new Log4jXmlObjectMapper(), bufferSize, charset, EVENT_END);
- }
-
- @Override
- protected int[] getEventIndices(final String text, final int beginIndex) {
- int start = text.indexOf(EVENT_START_NS_Y, beginIndex);
- int startLen = EVENT_START_NS_Y.length();
- if (start < 0) {
- start = text.indexOf(EVENT_START_NS_N, beginIndex);
- startLen = EVENT_START_NS_N.length();
- }
- final int end = start < 0 ? -1 : text.indexOf(EVENT_END, start + startLen);
- return new int[] { start, end };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/package-info.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/package-info.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/package-info.java
deleted file mode 100644
index 0d9d027..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-/**
- * Standalone server classes for consuming log events over a network. Each of the various servers should be used with
- * another Log4j configuration to handle incoming {@link org.apache.logging.log4j.core.LogEvent}s. It is recommended
- * to consider using the <a href="../../../../../../../../../manual/appenders.html#FlumeAppender">Flume Appender</a>
- * for highly reliable networked logging.
- */
-package org.apache.logging.log4j.core.net.server;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/AbstractSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/AbstractSocketServerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/AbstractSocketServerTest.java
deleted file mode 100644
index 7351313..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/AbstractSocketServerTest.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.AppenderLoggingException;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.core.appender.SocketAppender;
-import org.apache.logging.log4j.core.layout.JsonLayout;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.core.layout.XmlLayout;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.apache.logging.log4j.test.AvailablePortFinder;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- *
- */
-public abstract class AbstractSocketServerTest {
-
- protected static Thread thread;
-
- private static final String MESSAGE = "This is test message";
-
- private static final String MESSAGE_2 = "This is test message 2";
-
- private static final String MESSAGE_WITH_SPECIAL_CHARS = "{This}\n[is]\"n\"a\"\r\ntrue:\n\ttest,\nmessage";
-
- static final int PORT_NUM = AvailablePortFinder.getNextAvailable();
-
- static final int PORT = PORT_NUM;
-
- private final LoggerContext ctx = LoggerContext.getContext(false);
-
- private final boolean expectLengthException;
-
- protected final int port;
-
- protected final Protocol protocol;
-
- private final Logger rootLogger = ctx.getLogger(AbstractSocketServerTest.class.getSimpleName());
-
- protected AbstractSocketServerTest(final Protocol protocol, final int port, final boolean expectLengthException) {
- this.protocol = protocol;
- this.port = port;
- this.expectLengthException = expectLengthException;
- }
-
- protected Layout<String> createJsonLayout() {
- // @formatter: off
- return JsonLayout.newBuilder()
- .setLocationInfo(true)
- .setProperties(true)
- .setPropertiesAsList(false)
- .setComplete(false)
- .setCompact(false)
- .setEventEol(false)
- .setIncludeStacktrace(true)
- .build();
- // @formatter: on
-
- //return JsonLayout.createLayout(null, true, true, false, false, false, false, null, null, null, true);
- }
-
- protected abstract Layout<? extends Serializable> createLayout();
-
- protected Layout<? extends Serializable> createSerializedLayout() {
- return null;
- }
-
- protected Layout<String> createXmlLayout() {
- return XmlLayout.createLayout(true, true, false, false, null, true);
- }
-
- @After
- public void tearDown() {
- final Map<String, Appender> map = rootLogger.getAppenders();
- for (final Map.Entry<String, Appender> entry : map.entrySet()) {
- final Appender appender = entry.getValue();
- rootLogger.removeAppender(appender);
- appender.stop();
- }
- }
-
- @Test
- @Ignore("Broken test?")
- public void test1000ShortMessages() throws Exception {
- testServer(1000);
- }
-
- @Test
- @Ignore("Broken test?")
- public void test100ShortMessages() throws Exception {
- testServer(100);
- }
-
- @Test
- public void test10ShortMessages() throws Exception {
- testServer(10);
- }
-
- @Test
- public void test1ShortMessages() throws Exception {
- testServer(1);
- }
-
- @Test
- public void test2ShortMessages() throws Exception {
- testServer(2);
- }
-
- @Test
- public void test64KBMessages() throws Exception {
- final char[] a64K = new char[1024 * 64];
- Arrays.fill(a64K, 'a');
- final String m1 = new String(a64K);
- final String m2 = MESSAGE_2 + m1;
- if (expectLengthException) {
- try {
- testServer(m1, m2);
- } catch (final AppenderLoggingException are) {
- assertTrue("", are.getCause() != null && are.getCause() instanceof IOException);
- // Failure expected.
- }
- } else {
- testServer(m1, m2);
- }
- }
-
-
- @Test
- public void testMessagesWithSpecialChars() throws Exception {
- testServer(MESSAGE_WITH_SPECIAL_CHARS);
- }
-
-
- private void testServer(final int size) throws Exception {
- final String[] messages = new String[size];
- for (int i = 0; i < messages.length; i++) {
- messages[i] = MESSAGE + " " + i;
- }
- testServer(messages);
- }
-
- protected void testServer(final String... messages) throws Exception {
- final Filter socketFilter = new ThreadNameFilter(Filter.Result.NEUTRAL, Filter.Result.DENY);
- final Filter serverFilter = new ThreadNameFilter(Filter.Result.DENY, Filter.Result.NEUTRAL);
- final Layout<? extends Serializable> socketLayout = createLayout();
- final SocketAppender socketAppender = createSocketAppender(socketFilter, socketLayout);
- socketAppender.start();
- final ListAppender listAppender = new ListAppender("Events", serverFilter, null, false, false);
- listAppender.start();
- final PatternLayout layout = PatternLayout.newBuilder().withPattern("%m %ex%n").build();
- final ConsoleAppender console = ConsoleAppender.createDefaultAppenderForLayout(layout);
- final Logger serverLogger = ctx.getLogger(this.getClass().getName());
- serverLogger.addAppender(console);
- serverLogger.setAdditive(false);
-
- // set appender on root and set level to debug
- rootLogger.addAppender(socketAppender);
- rootLogger.addAppender(listAppender);
- rootLogger.setAdditive(false);
- rootLogger.setLevel(Level.DEBUG);
- for (final String message : messages) {
- rootLogger.debug(message);
- }
- final int MAX_TRIES = 400;
- for (int i = 0; i < MAX_TRIES; i++) {
- if (listAppender.getEvents().size() < messages.length) {
- try {
- // Let the server-side read the messages.
- Thread.sleep(50);
- } catch (final Exception e) {
- e.printStackTrace();
- }
- } else {
- break;
- }
- }
- final List<LogEvent> events = listAppender.getEvents();
- assertNotNull("No event retrieved", events);
- assertEquals("Incorrect number of events received", messages.length, events.size());
- for (int i = 0; i < messages.length; i++) {
- assertTrue("Incorrect event", events.get(i).getMessage().getFormattedMessage().equals(messages[i]));
- }
- }
-
- protected SocketAppender createSocketAppender(final Filter socketFilter,
- final Layout<? extends Serializable> socketLayout) {
- // @formatter:off
- return SocketAppender.newBuilder()
- .withProtocol(this.protocol)
- .withHost("localhost")
- .withPort(this.port)
- .withReconnectDelayMillis(-1)
- .withName("test")
- .withImmediateFlush(true)
- .withImmediateFail(false)
- .withIgnoreExceptions(false)
- .withLayout(socketLayout)
- .withFilter(socketFilter)
- .build();
- // @formatter:on
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/SslXmlSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/SslXmlSocketServerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/SslXmlSocketServerTest.java
deleted file mode 100644
index 8ca07a4..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/SslXmlSocketServerTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.nio.charset.Charset;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.SocketAppender;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.apache.logging.log4j.core.net.ssl.KeyStoreConfiguration;
-import org.apache.logging.log4j.core.net.ssl.SslConfiguration;
-import org.apache.logging.log4j.core.net.ssl.StoreConfigurationException;
-import org.apache.logging.log4j.core.net.ssl.TestConstants;
-import org.apache.logging.log4j.core.net.ssl.TrustStoreConfiguration;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class SslXmlSocketServerTest extends AbstractSocketServerTest {
-
- private static TcpSocketServer<InputStream> server;
-
- private static SslConfiguration sslConfiguration;
-
- private static void initServerSocketFactory() throws StoreConfigurationException {
- final KeyStoreConfiguration ksc = new KeyStoreConfiguration(TestConstants.KEYSTORE_FILE,
- TestConstants.KEYSTORE_PWD, TestConstants.KEYSTORE_TYPE, null);
- final TrustStoreConfiguration tsc = new TrustStoreConfiguration(TestConstants.TRUSTSTORE_FILE,
- TestConstants.TRUSTSTORE_PWD, null, null);
- sslConfiguration = SslConfiguration.createSSLConfiguration(null, ksc, tsc);
- }
-
- @Override
- protected SocketAppender createSocketAppender(final Filter socketFilter,
- final Layout<? extends Serializable> socketLayout) {
- // @formatter:off
- return SocketAppender.newBuilder()
- .withProtocol(this.protocol)
- .withHost("localhost")
- .withPort(this.port)
- .withReconnectDelayMillis(-1)
- .withName("test")
- .withImmediateFlush(true)
- .withImmediateFail(false)
- .withIgnoreExceptions(false)
- .withLayout(socketLayout)
- .withFilter(socketFilter)
- .withSslConfiguration(sslConfiguration)
- .build();
- // @formatter:on
- }
-
- @BeforeClass
- public static void setupClass() throws Exception {
- (LoggerContext.getContext(false)).reconfigure();
- initServerSocketFactory();
- // Use a large buffer just to test the code, the UDP test uses a tiny buffer
- server = new SecureTcpSocketServer<>(PORT_NUM, new XmlInputStreamLogEventBridge(1024 * 100,
- Charset.defaultCharset()), sslConfiguration);
- thread = server.startNewThread();
- }
-
- @AfterClass
- public static void tearDownClass() {
- try {
- server.shutdown();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- try {
- thread.join();
- } catch (final InterruptedException e) {
- // ignore
- }
- }
-
- public SslXmlSocketServerTest() {
- super(Protocol.SSL, PORT, false);
- }
-
- @Override
- protected Layout<String> createLayout() {
- return super.createXmlLayout();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpJsonSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpJsonSocketServerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpJsonSocketServerTest.java
deleted file mode 100644
index 6420e7e..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpJsonSocketServerTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class TcpJsonSocketServerTest extends AbstractSocketServerTest {
-
- private static TcpSocketServer<InputStream> server;
-
- @BeforeClass
- public static void setupClass() throws Exception {
- (LoggerContext.getContext(false)).reconfigure();
- server = TcpSocketServer.createJsonSocketServer(PORT_NUM);
- thread = server.startNewThread();
- }
-
- @AfterClass
- public static void tearDownClass() {
- try {
- server.shutdown();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- try {
- thread.join();
- } catch (final InterruptedException e) {
- // ignore
- }
- }
-
- public TcpJsonSocketServerTest() {
- super(Protocol.TCP, PORT, false);
- }
-
- @Override
- protected Layout<String> createLayout() {
- return super.createJsonLayout();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f515fa3c/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpSerializedSocketServerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpSerializedSocketServerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpSerializedSocketServerTest.java
deleted file mode 100644
index 645701b..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/server/TcpSerializedSocketServerTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.net.server;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class TcpSerializedSocketServerTest extends AbstractSocketServerTest {
-
- private static TcpSocketServer<ObjectInputStream> server;
-
- @BeforeClass
- public static void setupClass() throws Exception {
- (LoggerContext.getContext(false)).reconfigure();
- server = TcpSocketServer.createSerializedSocketServer(PORT_NUM);
- thread = server.startNewThread();
- }
-
- @AfterClass
- public static void tearDownClass() {
- try {
- server.shutdown();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- try {
- thread.join();
- } catch (final InterruptedException e) {
- // ignore
- }
- }
-
- public TcpSerializedSocketServerTest() {
- super(Protocol.TCP, PORT, false);
- }
-
- @Override
- protected Layout<? extends Serializable> createLayout() {
- return super.createSerializedLayout();
- }
-
-}
[13/14] logging-log4j2 git commit: Bump version number
Posted by mi...@apache.org.
Bump version number
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/10510813
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/10510813
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/10510813
Branch: refs/heads/master
Commit: 10510813f4f23a4b6e2f9568bfb7b6253d144a26
Parents: ea14d1c
Author: Mikael St�ldal <mi...@magine.com>
Authored: Mon Apr 10 12:19:36 2017 +0200
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Mon Apr 10 12:19:36 2017 +0200
----------------------------------------------------------------------
log4j-server/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/10510813/log4j-server/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-server/pom.xml b/log4j-server/pom.xml
index 3a370b4..f6aed3d 100644
--- a/log4j-server/pom.xml
+++ b/log4j-server/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
- <version>2.8.2-SNAPSHOT</version>
+ <version>2.8.3-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-server</artifactId>
[06/14] logging-log4j2 git commit: Merge branch 'master' into
LOG4J2-1851
Posted by mi...@apache.org.
Merge branch 'master' into LOG4J2-1851
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/873e7efb
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/873e7efb
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/873e7efb
Branch: refs/heads/master
Commit: 873e7efbab22aac29e29716a871ff114c60202bd
Parents: b77b7d0 30afee1
Author: Mikael St�ldal <mi...@magine.com>
Authored: Fri Mar 17 16:04:59 2017 +0100
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Fri Mar 17 16:04:59 2017 +0100
----------------------------------------------------------------------
.../test/resources/org/apache/logging/log4j/core/net/ssl/README | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
[05/14] logging-log4j2 git commit: Merge branch 'master' into
log4j-server
Posted by mi...@apache.org.
Merge branch 'master' into log4j-server
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b77b7d03
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b77b7d03
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b77b7d03
Branch: refs/heads/master
Commit: b77b7d039653bc1675e7f9a1376cedf9e4fd16c5
Parents: f515fa3 c822338
Author: Mikael St�ldal <mi...@magine.com>
Authored: Fri Mar 17 14:59:48 2017 +0100
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Fri Mar 17 16:03:24 2017 +0100
----------------------------------------------------------------------
.../core/util/datetime/FixedDateFormat.java | 32 +-
.../core/util/datetime/FixedDateFormatTest.java | 177 ++++++++++-
log4j-server/pom.xml | 25 +-
.../core/net/mom/jms/AbstractJmsReceiver.java | 48 ---
.../core/net/mom/jms/JmsQueueReceiver.java | 46 ---
.../core/net/mom/jms/JmsTopicReceiver.java | 46 ---
.../log4j/core/net/mom/jms/package-info.java | 26 --
.../core/net/server/AbstractLogEventBridge.java | 44 ---
.../core/net/server/AbstractSocketServer.java | 209 ------------
.../net/server/InputStreamLogEventBridge.java | 103 ------
.../log4j/core/net/server/JmsServer.java | 148 ---------
.../server/JsonInputStreamLogEventBridge.java | 90 ------
.../log4j/core/net/server/LogEventBridge.java | 57 ----
.../server/ObjectInputStreamLogEventBridge.java | 45 ---
.../core/net/server/SecureTcpSocketServer.java | 37 ---
.../log4j/core/net/server/TcpSocketServer.java | 314 -------------------
.../log4j/core/net/server/UdpSocketServer.java | 169 ----------
.../server/XmlInputStreamLogEventBridge.java | 54 ----
.../log4j/core/net/server/package-info.java | 24 --
.../log4j/server/AbstractLogEventBridge.java | 44 +++
.../log4j/server/AbstractSocketServer.java | 209 ++++++++++++
.../log4j/server/InputStreamLogEventBridge.java | 103 ++++++
.../apache/logging/log4j/server/JmsServer.java | 148 +++++++++
.../server/JsonInputStreamLogEventBridge.java | 90 ++++++
.../logging/log4j/server/LogEventBridge.java | 57 ++++
.../server/ObjectInputStreamLogEventBridge.java | 45 +++
.../log4j/server/SecureTcpSocketServer.java | 37 +++
.../logging/log4j/server/TcpSocketServer.java | 314 +++++++++++++++++++
.../logging/log4j/server/UdpSocketServer.java | 169 ++++++++++
.../server/XmlInputStreamLogEventBridge.java | 54 ++++
.../server/mom/jms/AbstractJmsReceiver.java | 48 +++
.../log4j/server/mom/jms/JmsQueueReceiver.java | 46 +++
.../log4j/server/mom/jms/JmsTopicReceiver.java | 46 +++
.../log4j/server/mom/jms/package-info.java | 26 ++
.../logging/log4j/server/package-info.java | 24 ++
log4j-server/src/site/markdown/index.md | 7 +-
.../net/server/AbstractSocketServerTest.java | 237 --------------
.../core/net/server/SslXmlSocketServerTest.java | 104 ------
.../net/server/TcpJsonSocketServerTest.java | 62 ----
.../server/TcpSerializedSocketServerTest.java | 63 ----
.../core/net/server/TcpXmlSocketServerTest.java | 65 ----
.../log4j/core/net/server/ThreadIdFilter.java | 40 ---
.../log4j/core/net/server/ThreadNameFilter.java | 39 ---
.../core/net/server/ThreadPriorityFilter.java | 40 ---
.../net/server/UdpJsonSocketServerTest.java | 58 ----
.../server/UdpSerializedSocketServerTest.java | 60 ----
.../core/net/server/UdpXmlSocketServerTest.java | 61 ----
.../log4j/server/AbstractSocketServerTest.java | 237 ++++++++++++++
.../log4j/server/SslXmlSocketServerTest.java | 104 ++++++
.../log4j/server/TcpJsonSocketServerTest.java | 62 ++++
.../server/TcpSerializedSocketServerTest.java | 63 ++++
.../log4j/server/TcpXmlSocketServerTest.java | 65 ++++
.../logging/log4j/server/ThreadIdFilter.java | 40 +++
.../logging/log4j/server/ThreadNameFilter.java | 39 +++
.../log4j/server/ThreadPriorityFilter.java | 40 +++
.../log4j/server/UdpJsonSocketServerTest.java | 58 ++++
.../server/UdpSerializedSocketServerTest.java | 60 ++++
.../log4j/server/UdpXmlSocketServerTest.java | 61 ++++
.../core/net/ssl/client.log4j2-keystore.jks | Bin 0 -> 6829 bytes
.../logging/log4j/core/net/ssl/truststore.jks | Bin 0 -> 1487 bytes
src/changes/changes.xml | 3 +
61 files changed, 2516 insertions(+), 2306 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/pom.xml
----------------------------------------------------------------------
diff --cc log4j-server/pom.xml
index 2833871,0000000..3a370b4
mode 100644,000000..100644
--- a/log4j-server/pom.xml
+++ b/log4j-server/pom.xml
@@@ -1,197 -1,0 +1,220 @@@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>2.8.2-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+ <artifactId>log4j-server</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Log4j Server components</name>
+ <description>The Apache Log4j server components</description>
+ <properties>
+ <log4jParentDir>${basedir}/..</log4jParentDir>
+ <projectDir>/log4j-server</projectDir>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ </dependency>
- <!-- Command line for TCP and UDP servers -->
++ <!-- Command line parsing -->
+ <dependency>
+ <groupId>com.beust</groupId>
+ <artifactId>jcommander</artifactId>
+ </dependency>
++ <!-- Used for JMS server (needs an implementation of course) -->
++ <dependency>
++ <groupId>org.jboss.spec.javax.jms</groupId>
++ <artifactId>jboss-jms-api_1.1_spec</artifactId>
++ <scope>provided</scope>
++ <optional>true</optional>
++ </dependency>
++ <!-- Required for JSON support -->
++ <dependency>
++ <groupId>com.fasterxml.jackson.core</groupId>
++ <artifactId>jackson-databind</artifactId>
++ </dependency>
++ <!-- Required for XML support -->
++ <dependency>
++ <groupId>com.fasterxml.jackson.dataformat</groupId>
++ <artifactId>jackson-dataformat-xml</artifactId>
++ </dependency>
++ <!-- POM for jackson-dataformat-xml 2.8.3 depends on woodstox-core 5.0.2 -->
++ <dependency>
++ <groupId>com.fasterxml.woodstox</groupId>
++ <artifactId>woodstox-core</artifactId>
++ <version>5.0.2</version>
++ </dependency>
+
+ <!-- TEST DEPENDENCIES -->
+
+ <!-- Pull in useful test classes from API -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <!-- Include the standard NOTICE and LICENSE -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>org.apache.logging.log4j.core.net.*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changes-plugin</artifactId>
+ <version>${changes.plugin.version}</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>changes-report</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ <configuration>
+ <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
+ <useJql>true</useJql>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${checkstyle.plugin.version}</version>
+ <configuration>
+ <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
+ <configLocation>${log4jParentDir}/checkstyle.xml</configLocation>
+ <suppressionsLocation>${log4jParentDir}/checkstyle-suppressions.xml</suppressionsLocation>
+ <enableRulesSummary>false</enableRulesSummary>
+ <propertyExpansion>basedir=${basedir}</propertyExpansion>
+ <propertyExpansion>licensedir=${log4jParentDir}/checkstyle-header.txt</propertyExpansion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>${javadoc.plugin.version}</version>
+ <configuration>
+ <bottom><![CDATA[<p align="center">Copyright © {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.<br />
+ Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo,
+ and the Apache Log4j logo are trademarks of The Apache Software Foundation.</p>]]></bottom>
+ <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
+ project -->
+ <detectOfflineLinks>false</detectOfflineLinks>
+ <linksource>true</linksource>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <id>non-aggregate</id>
+ <reports>
+ <report>javadoc</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>${findbugs.plugin.version}</version>
+ <configuration>
+ <fork>true</fork>
+ <jvmArgs>-Duser.language=en</jvmArgs>
+ <threshold>Normal</threshold>
+ <effort>Default</effort>
+ <excludeFilterFile>${log4jParentDir}/findbugs-exclude-filter.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>${jxr.plugin.version}</version>
+ <reportSets>
+ <reportSet>
+ <id>non-aggregate</id>
+ <reports>
+ <report>jxr</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>${pmd.plugin.version}</version>
+ <configuration>
+ <targetJdk>${maven.compiler.target}</targetJdk>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
+
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/AbstractLogEventBridge.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/AbstractLogEventBridge.java
index 0000000,0000000..5e368cb
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/AbstractLogEventBridge.java
@@@ -1,0 -1,0 +1,44 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.InputStream;
++
++import org.apache.logging.log4j.Logger;
++import org.apache.logging.log4j.status.StatusLogger;
++
++/**
++ * Abstract class for implementations of {@link LogEventBridge}.
++ *
++ * @param <T>
++ * The kind of input stream read
++ */
++public abstract class AbstractLogEventBridge<T extends InputStream> implements LogEventBridge<T> {
++
++ protected static final int END = -1;
++
++ protected static final Logger logger = StatusLogger.getLogger();
++
++ // The default is to return the same object as given.
++ @SuppressWarnings("unchecked")
++ @Override
++ public T wrapStream(final InputStream inputStream) throws IOException {
++ return (T) inputStream;
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/AbstractSocketServer.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/AbstractSocketServer.java
index 0000000,0000000..a8f1140
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/AbstractSocketServer.java
@@@ -1,0 -1,0 +1,209 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.BufferedReader;
++import java.io.File;
++import java.io.FileInputStream;
++import java.io.FileNotFoundException;
++import java.io.IOException;
++import java.io.InputStream;
++import java.io.InputStreamReader;
++import java.net.InetAddress;
++import java.net.URI;
++import java.net.URL;
++import java.util.Objects;
++
++import com.beust.jcommander.Parameter;
++import com.beust.jcommander.validators.PositiveInteger;
++import org.apache.logging.log4j.LogManager;
++import org.apache.logging.log4j.Logger;
++import org.apache.logging.log4j.core.LogEventListener;
++import org.apache.logging.log4j.core.LoggerContext;
++import org.apache.logging.log4j.core.config.Configuration;
++import org.apache.logging.log4j.core.config.ConfigurationSource;
++import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
++import org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory;
++import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
++import org.apache.logging.log4j.core.util.InetAddressConverter;
++import org.apache.logging.log4j.core.util.Log4jThread;
++import org.apache.logging.log4j.util.Strings;
++
++/**
++ * Abstract socket server for TCP and UDP implementations.
++ *
++ * @param <T>
++ * The kind of input stream read
++ *
++ * TODO Make a LifeCycle
++ */
++public abstract class AbstractSocketServer<T extends InputStream> extends LogEventListener implements Runnable {
++
++ protected static class CommandLineArguments extends BasicCommandLineArguments {
++
++ @Parameter(names = { "--config", "-c" }, description = "Log4j configuration file location (path or URL).")
++ private String configLocation;
++
++ @Parameter(names = { "--interactive",
++ "-i" }, description = "Accepts commands on standard input (\"exit\" is the only command).")
++ private boolean interactive;
++
++ @Parameter(names = { "--port",
++ "-p" }, validateWith = PositiveInteger.class, description = "Server socket port.")
++ private int port;
++
++ @Parameter(names = { "--localbindaddress",
++ "-a" }, converter = InetAddressConverter.class, description = "Server socket local bind address.")
++ private InetAddress localBindAddress;
++
++ String getConfigLocation() {
++ return configLocation;
++ }
++
++ int getPort() {
++ return port;
++ }
++
++ protected boolean isInteractive() {
++ return interactive;
++ }
++
++ void setConfigLocation(final String configLocation) {
++ this.configLocation = configLocation;
++ }
++
++ void setInteractive(final boolean interactive) {
++ this.interactive = interactive;
++ }
++
++ void setPort(final int port) {
++ this.port = port;
++ }
++
++ InetAddress getLocalBindAddress() {
++ return localBindAddress;
++ }
++
++ void setLocalBindAddress(final InetAddress localBindAddress) {
++ this.localBindAddress = localBindAddress;
++ }
++ }
++
++ /**
++ * Factory that creates a Configuration for the server.
++ */
++ protected static class ServerConfigurationFactory extends XmlConfigurationFactory {
++
++ private final String path;
++
++ public ServerConfigurationFactory(final String path) {
++ this.path = path;
++ }
++
++ @Override
++ public Configuration getConfiguration(final LoggerContext loggerContext, final String name,
++ final URI configLocation) {
++ if (Strings.isNotEmpty(path)) {
++ File file = null;
++ ConfigurationSource source = null;
++ try {
++ file = new File(path);
++ final FileInputStream is = new FileInputStream(file);
++ source = new ConfigurationSource(is, file);
++ } catch (final FileNotFoundException ignored) {
++ // Ignore this error
++ }
++ if (source == null) {
++ try {
++ final URL url = new URL(path);
++ source = new ConfigurationSource(url.openStream(), url);
++ } catch (final IOException ignored) {
++ // Ignore this error
++ }
++ }
++
++ try {
++ if (source != null) {
++ return new XmlConfiguration(loggerContext, source);
++ }
++ } catch (final Exception ignored) {
++ // Ignore this error.
++ }
++ System.err.println("Unable to process configuration at " + path + ", using default.");
++ }
++ return super.getConfiguration(loggerContext, name, configLocation);
++ }
++ }
++
++ protected static final int MAX_PORT = 65534;
++
++ private volatile boolean active = true;
++
++ protected final LogEventBridge<T> logEventInput;
++
++ protected final Logger logger;
++
++ /**
++ * Creates a new socket server.
++ *
++ * @param port
++ * listen to this port
++ * @param logEventInput
++ * Use this input to read log events.
++ */
++ public AbstractSocketServer(final int port, final LogEventBridge<T> logEventInput) {
++ this.logger = LogManager.getLogger(this.getClass().getName() + '.' + port);
++ this.logEventInput = Objects.requireNonNull(logEventInput, "LogEventInput");
++ }
++
++ protected boolean isActive() {
++ return this.active;
++ }
++
++ protected void setActive(final boolean isActive) {
++ this.active = isActive;
++ }
++
++ /**
++ * Start this server in a new thread.
++ *
++ * @return the new thread that running this server.
++ */
++ public Thread startNewThread() {
++ final Thread thread = new Log4jThread(this);
++ thread.start();
++ return thread;
++ }
++
++ public abstract void shutdown() throws Exception;
++
++ public void awaitTermination(final Thread serverThread) throws Exception {
++ final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
++ while (true) {
++ final String line = reader.readLine();
++ if (line == null
++ || line.equalsIgnoreCase("quit")
++ || line.equalsIgnoreCase("stop")
++ || line.equalsIgnoreCase("exit")) {
++ this.shutdown();
++ serverThread.join();
++ break;
++ }
++ }
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/InputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/InputStreamLogEventBridge.java
index 0000000,0000000..68ec791
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/InputStreamLogEventBridge.java
@@@ -1,0 -1,0 +1,103 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.InputStream;
++import java.nio.charset.Charset;
++
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.LogEventListener;
++import org.apache.logging.log4j.core.impl.Log4jLogEvent;
++import org.apache.logging.log4j.util.Strings;
++
++import com.fasterxml.jackson.databind.ObjectMapper;
++import com.fasterxml.jackson.databind.ObjectReader;
++
++/**
++ * Reads and logs {@link LogEvent}s from an {@link InputStream}.
++ */
++public abstract class InputStreamLogEventBridge extends AbstractLogEventBridge<InputStream> {
++
++ private final int bufferSize;
++
++ private final Charset charset;
++
++ private final String eventEndMarker;
++
++ private final ObjectReader objectReader;
++
++ public InputStreamLogEventBridge(final ObjectMapper mapper, final int bufferSize, final Charset charset, final String eventEndMarker) {
++ this.bufferSize = bufferSize;
++ this.charset = charset;
++ this.eventEndMarker = eventEndMarker;
++ this.objectReader = mapper.readerFor(Log4jLogEvent.class);
++ }
++
++ abstract protected int[] getEventIndices(final String text, int beginIndex);
++
++ @Override
++ public void logEvents(final InputStream inputStream, final LogEventListener logEventListener) throws IOException {
++ String workingText = Strings.EMPTY;
++ try {
++ // Allocate buffer once
++ final byte[] buffer = new byte[bufferSize];
++ String textRemains = workingText = Strings.EMPTY;
++ while (true) {
++ // Process until the stream is EOF.
++ final int streamReadLength = inputStream.read(buffer);
++ if (streamReadLength == END) {
++ // The input stream is EOF
++ break;
++ }
++ final String text = workingText = textRemains + new String(buffer, 0, streamReadLength, charset);
++ int beginIndex = 0;
++ while (true) {
++ // Extract and log all XML events in the buffer
++ final int[] pair = getEventIndices(text, beginIndex);
++ final int eventStartMarkerIndex = pair[0];
++ if (eventStartMarkerIndex < 0) {
++ // No more events or partial XML only in the buffer.
++ // Save the unprocessed string part
++ textRemains = text.substring(beginIndex);
++ break;
++ }
++ final int eventEndMarkerIndex = pair[1];
++ if (eventEndMarkerIndex > 0) {
++ final int eventEndXmlIndex = eventEndMarkerIndex + eventEndMarker.length();
++ final String textEvent = workingText = text.substring(eventStartMarkerIndex, eventEndXmlIndex);
++ final LogEvent logEvent = unmarshal(textEvent);
++ logEventListener.log(logEvent);
++ beginIndex = eventEndXmlIndex;
++ } else {
++ // No more events or partial XML only in the buffer.
++ // Save the unprocessed string part
++ textRemains = text.substring(beginIndex);
++ break;
++ }
++ }
++ }
++ } catch (final IOException ex) {
++ logger.error(workingText, ex);
++ }
++ }
++
++ protected Log4jLogEvent unmarshal(final String jsonEvent) throws IOException {
++ return this.objectReader.readValue(jsonEvent);
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/JmsServer.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/JmsServer.java
index 0000000,0000000..b673c06
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/JmsServer.java
@@@ -1,0 -1,0 +1,148 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++package org.apache.logging.log4j.server;
++
++import java.io.BufferedReader;
++import java.io.IOException;
++import java.io.InputStreamReader;
++import java.nio.charset.Charset;
++import java.util.concurrent.TimeUnit;
++import java.util.concurrent.atomic.AtomicReference;
++import javax.jms.JMSException;
++import javax.jms.Message;
++import javax.jms.MessageConsumer;
++import javax.jms.MessageListener;
++import javax.jms.ObjectMessage;
++
++import org.apache.logging.log4j.LoggingException;
++import org.apache.logging.log4j.core.AbstractLifeCycle;
++import org.apache.logging.log4j.core.LifeCycle2;
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.LogEventListener;
++import org.apache.logging.log4j.core.appender.mom.JmsManager;
++import org.apache.logging.log4j.core.net.JndiManager;
++
++/**
++ * LogEventListener server that receives LogEvents over a JMS {@link javax.jms.Destination}.
++ *
++ * @since 2.1
++ */
++public class JmsServer extends LogEventListener implements MessageListener, LifeCycle2 {
++
++ private final AtomicReference<State> state = new AtomicReference<>(State.INITIALIZED);
++ private final JmsManager jmsManager;
++ private MessageConsumer messageConsumer;
++
++ public JmsServer(final String connectionFactoryBindingName,
++ final String destinationBindingName,
++ final String username,
++ final String password) {
++ final String managerName = JmsServer.class.getName() + '@' + JmsServer.class.hashCode();
++ final JndiManager jndiManager = JndiManager.getDefaultManager(managerName);
++ jmsManager = JmsManager.getJmsManager(managerName, jndiManager, connectionFactoryBindingName,
++ destinationBindingName, username, password);
++ }
++
++ @Override
++ public State getState() {
++ return state.get();
++ }
++
++ @Override
++ public void onMessage(final Message message) {
++ try {
++ if (message instanceof ObjectMessage) {
++ final Object body = ((ObjectMessage) message).getObject();
++ if (body instanceof LogEvent) {
++ log((LogEvent) body);
++ } else {
++ LOGGER.warn("Expected ObjectMessage to contain LogEvent. Got type {} instead.", body.getClass());
++ }
++ } else {
++ LOGGER.warn("Received message of type {} and JMSType {} which cannot be handled.", message.getClass(),
++ message.getJMSType());
++ }
++ } catch (final JMSException e) {
++ LOGGER.catching(e);
++ }
++ }
++
++ @Override
++ public void initialize() {
++ }
++
++ @Override
++ public void start() {
++ if (state.compareAndSet(State.INITIALIZED, State.STARTING)) {
++ try {
++ messageConsumer = jmsManager.createMessageConsumer();
++ messageConsumer.setMessageListener(this);
++ } catch (final JMSException e) {
++ throw new LoggingException(e);
++ }
++ }
++ }
++
++ @Override
++ public void stop() {
++ stop(AbstractLifeCycle.DEFAULT_STOP_TIMEOUT, AbstractLifeCycle.DEFAULT_STOP_TIMEUNIT);
++ }
++
++ @Override
++ public boolean stop(final long timeout, final TimeUnit timeUnit) {
++ boolean stopped = true;
++ try {
++ messageConsumer.close();
++ } catch (final JMSException e) {
++ LOGGER.debug("Exception closing {}", messageConsumer, e);
++ stopped = false;
++ }
++ return stopped && jmsManager.stop(timeout, timeUnit);
++ }
++
++ @Override
++ public boolean isStarted() {
++ return state.get() == State.STARTED;
++ }
++
++ @Override
++ public boolean isStopped() {
++ return state.get() == State.STOPPED;
++ }
++
++ /**
++ * Starts and runs this server until the user types "exit" into standard input.
++ *
++ * @throws IOException
++ * @since 2.6
++ */
++ public void run() throws IOException {
++ this.start();
++ System.out.println("Type \"exit\" to quit.");
++ final BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in, Charset.defaultCharset()));
++ while (true) {
++ final String line = stdin.readLine();
++ if (line == null || line.equalsIgnoreCase("exit")) {
++ System.out.println("Exiting. Kill the application if it does not exit due to daemon threads.");
++ this.stop();
++ return;
++ }
++ }
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/JsonInputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/JsonInputStreamLogEventBridge.java
index 0000000,0000000..6a06ae4
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/JsonInputStreamLogEventBridge.java
@@@ -1,0 -1,0 +1,90 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.InputStream;
++import java.nio.charset.Charset;
++
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.jackson.Log4jJsonObjectMapper;
++import org.apache.logging.log4j.util.Chars;
++
++/**
++ * Reads and logs JSON {@link LogEvent}s from an {@link InputStream}..
++ */
++public class JsonInputStreamLogEventBridge extends InputStreamLogEventBridge {
++
++ private static final int[] END_PAIR = new int[] { END, END };
++ private static final char EVENT_END_MARKER = '}';
++ private static final char EVENT_START_MARKER = '{';
++ private static final char JSON_ESC = '\\';
++ private static final char JSON_STR_DELIM = Chars.DQUOTE;
++ private static final boolean THREAD_CONTEXT_MAP_AS_LIST = false;
++
++ public JsonInputStreamLogEventBridge() {
++ this(1024, Charset.defaultCharset());
++ }
++
++ public JsonInputStreamLogEventBridge(final int bufferSize, final Charset charset) {
++ super(new Log4jJsonObjectMapper(THREAD_CONTEXT_MAP_AS_LIST, true), bufferSize, charset,
++ String.valueOf(EVENT_END_MARKER));
++ }
++
++ @Override
++ protected int[] getEventIndices(final String text, final int beginIndex) {
++ // Scan the text for the end of the next JSON object.
++ final int start = text.indexOf(EVENT_START_MARKER, beginIndex);
++ if (start == END) {
++ return END_PAIR;
++ }
++ final char[] charArray = text.toCharArray();
++ int stack = 0;
++ boolean inStr = false;
++ boolean inEsc = false;
++ for (int i = start; i < charArray.length; i++) {
++ final char c = charArray[i];
++ if (inEsc) {
++ // Skip this char and continue
++ inEsc = false;
++ } else {
++ switch (c) {
++ case EVENT_START_MARKER:
++ if (!inStr) {
++ stack++;
++ }
++ break;
++ case EVENT_END_MARKER:
++ if (!inStr) {
++ stack--;
++ }
++ break;
++ case JSON_STR_DELIM:
++ inStr = !inStr;
++ break;
++ case JSON_ESC:
++ inEsc = true;
++ break;
++ }
++ if (stack == 0) {
++ return new int[] { start, i };
++ }
++ }
++ }
++ return END_PAIR;
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/LogEventBridge.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/LogEventBridge.java
index 0000000,0000000..785c365
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/LogEventBridge.java
@@@ -1,0 -1,0 +1,57 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.InputStream;
++
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.LogEventListener;
++
++/**
++ * Reads {@link LogEvent}s from the given input stream and logs them as they are discovered on the given logger.
++ *
++ * <p>
++ * Should be stateless.
++ * </p>
++ *
++ * @param <T>
++ * The kind of {@link InputStream} to wrap and read.
++ */
++public interface LogEventBridge<T extends InputStream> {
++
++ /**
++ * Reads {@link LogEvent}s from the given input stream and logs them as they are discovered on the given logger.
++ *
++ * @param inputStream
++ * the input stream to read
++ * @param logEventListener
++ * TODO
++ * @throws IOException
++ */
++ void logEvents(T inputStream, LogEventListener logEventListener) throws IOException;
++
++ /**
++ * Wraps the given stream if needed.
++ *
++ * @param inputStream
++ * the stream to wrap
++ * @return the wrapped stream or the given stream.
++ * @throws IOException
++ */
++ T wrapStream(InputStream inputStream) throws IOException;
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/ObjectInputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/ObjectInputStreamLogEventBridge.java
index 0000000,0000000..9f22b22
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/ObjectInputStreamLogEventBridge.java
@@@ -1,0 -1,0 +1,45 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.InputStream;
++import java.io.ObjectInputStream;
++
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.LogEventListener;
++
++/**
++ * Reads and logs serialized {@link LogEvent} objects from an {@link ObjectInputStream}.
++ */
++public class ObjectInputStreamLogEventBridge extends AbstractLogEventBridge<ObjectInputStream> {
++
++ @Override
++ public void logEvents(final ObjectInputStream inputStream, final LogEventListener logEventListener)
++ throws IOException {
++ try {
++ logEventListener.log((LogEvent) inputStream.readObject());
++ } catch (final ClassNotFoundException e) {
++ throw new IOException(e);
++ }
++ }
++
++ @Override
++ public ObjectInputStream wrapStream(final InputStream inputStream) throws IOException {
++ return new ObjectInputStream(inputStream);
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/SecureTcpSocketServer.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/SecureTcpSocketServer.java
index 0000000,0000000..81c9d64
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/SecureTcpSocketServer.java
@@@ -1,0 -1,0 +1,37 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.IOException;
++import java.io.InputStream;
++
++import org.apache.logging.log4j.core.net.ssl.SslConfiguration;
++
++/**
++ * Listens for events over a secure socket connection (SSL/TLS).
++ *
++ * @param <T>
++ * The kind of input stream read
++ */
++public class SecureTcpSocketServer<T extends InputStream> extends TcpSocketServer<T> {
++
++ public SecureTcpSocketServer(final int port, final LogEventBridge<T> logEventInput,
++ final SslConfiguration sslConfig) throws IOException {
++ super(port, logEventInput, sslConfig.getSslServerSocketFactory().createServerSocket(port));
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/TcpSocketServer.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/TcpSocketServer.java
index 0000000,0000000..7856969
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/TcpSocketServer.java
@@@ -1,0 -1,0 +1,314 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.EOFException;
++import java.io.IOException;
++import java.io.InputStream;
++import java.io.ObjectInputStream;
++import java.io.OptionalDataException;
++import java.net.InetAddress;
++import java.net.ServerSocket;
++import java.net.Socket;
++import java.util.Map;
++import java.util.concurrent.ConcurrentHashMap;
++import java.util.concurrent.ConcurrentMap;
++
++import com.beust.jcommander.Parameter;
++import com.beust.jcommander.validators.PositiveInteger;
++import org.apache.logging.log4j.core.config.ConfigurationFactory;
++import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
++import org.apache.logging.log4j.core.util.Closer;
++import org.apache.logging.log4j.core.util.Log4jThread;
++import org.apache.logging.log4j.message.EntryMessage;
++
++/**
++ * Listens for Log4j events on a TCP server socket and passes them on to Log4j.
++ *
++ * @param <T>
++ * The kind of input stream read
++ * @see #main(String[])
++ */
++public class TcpSocketServer<T extends InputStream> extends AbstractSocketServer<T> {
++
++ protected static class CommandLineArguments extends AbstractSocketServer.CommandLineArguments {
++
++ @Parameter(names = { "--backlog",
++ "-b" }, validateWith = PositiveInteger.class, description = "Server socket backlog.")
++ // Same default as ServerSocket
++ private int backlog = 50;
++
++ int getBacklog() {
++ return backlog;
++ }
++
++ void setBacklog(final int backlog) {
++ this.backlog = backlog;
++ }
++
++ }
++
++ /**
++ * Thread that processes the events.
++ */
++ private class SocketHandler extends Log4jThread {
++
++ private final T inputStream;
++
++ private volatile boolean shutdown = false;
++
++ public SocketHandler(final Socket socket) throws IOException {
++ this.inputStream = logEventInput.wrapStream(socket.getInputStream());
++ }
++
++ @Override
++ public void run() {
++ final EntryMessage entry = logger.traceEntry();
++ boolean closed = false;
++ try {
++ try {
++ while (!shutdown) {
++ logEventInput.logEvents(inputStream, TcpSocketServer.this);
++ }
++ } catch (final EOFException e) {
++ closed = true;
++ } catch (final OptionalDataException e) {
++ logger.error("OptionalDataException eof=" + e.eof + " length=" + e.length, e);
++ } catch (final IOException e) {
++ logger.error("IOException encountered while reading from socket", e);
++ }
++ if (!closed) {
++ Closer.closeSilently(inputStream);
++ }
++ } finally {
++ handlers.remove(Long.valueOf(getId()));
++ }
++ logger.traceExit(entry);
++ }
++
++ public void shutdown() {
++ this.shutdown = true;
++ interrupt();
++ }
++ }
++
++ /**
++ * Creates a socket server that reads JSON log events.
++ *
++ * @param port
++ * the port to listen
++ * @return a new a socket server
++ * @throws IOException
++ * if an I/O error occurs when opening the socket.
++ */
++ public static TcpSocketServer<InputStream> createJsonSocketServer(final int port) throws IOException {
++ LOGGER.entry("createJsonSocketServer", port);
++ final TcpSocketServer<InputStream> socketServer = new TcpSocketServer<>(port, new JsonInputStreamLogEventBridge());
++ return LOGGER.exit(socketServer);
++ }
++
++ /**
++ * Creates a socket server that reads serialized log events.
++ *
++ * @param port
++ * the port to listen
++ * @return a new a socket server
++ * @throws IOException
++ * if an I/O error occurs when opening the socket.
++ */
++ public static TcpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port) throws IOException {
++ LOGGER.entry(port);
++ final TcpSocketServer<ObjectInputStream> socketServer = new TcpSocketServer<>(port, new ObjectInputStreamLogEventBridge());
++ return LOGGER.exit(socketServer);
++ }
++
++ /**
++ * Creates a socket server that reads serialized log events.
++ *
++ * @param port the port to listen
++ * @param localBindAddress The server socket's local bin address
++ * @return a new a socket server
++ * @throws IOException
++ * if an I/O error occurs when opening the socket.
++ * @since 2.7
++ */
++ public static TcpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port, final int backlog,
++ final InetAddress localBindAddress) throws IOException {
++ LOGGER.entry(port);
++ final TcpSocketServer<ObjectInputStream> socketServer = new TcpSocketServer<>(port, backlog, localBindAddress,
++ new ObjectInputStreamLogEventBridge());
++ return LOGGER.exit(socketServer);
++ }
++
++ /**
++ * Creates a socket server that reads XML log events.
++ *
++ * @param port
++ * the port to listen
++ * @return a new a socket server
++ * @throws IOException
++ * if an I/O error occurs when opening the socket.
++ */
++ public static TcpSocketServer<InputStream> createXmlSocketServer(final int port) throws IOException {
++ LOGGER.entry(port);
++ final TcpSocketServer<InputStream> socketServer = new TcpSocketServer<>(port, new XmlInputStreamLogEventBridge());
++ return LOGGER.exit(socketServer);
++ }
++
++ /**
++ * Main startup for the server. Run with "--help" for to print command line help on the console.
++ *
++ * @param args
++ * The command line arguments.
++ * @throws Exception
++ * if an error occurs.
++ */
++ public static void main(final String[] args) throws Exception {
++ final CommandLineArguments cla = BasicCommandLineArguments.parseCommandLine(args, TcpSocketServer.class, new CommandLineArguments());
++ if (cla.isHelp()) {
++ return;
++ }
++ if (cla.getConfigLocation() != null) {
++ ConfigurationFactory.setConfigurationFactory(new ServerConfigurationFactory(cla.getConfigLocation()));
++ }
++ final TcpSocketServer<ObjectInputStream> socketServer = TcpSocketServer
++ .createSerializedSocketServer(cla.getPort(), cla.getBacklog(), cla.getLocalBindAddress());
++ final Thread serverThread = socketServer.startNewThread();
++ if (cla.isInteractive()) {
++ socketServer.awaitTermination(serverThread);
++ }
++ }
++
++ private final ConcurrentMap<Long, SocketHandler> handlers = new ConcurrentHashMap<>();
++
++ private final ServerSocket serverSocket;
++
++ /**
++ * Constructor.
++ *
++ * @param port
++ * The server socket port.
++ * @param backlog
++ * The server socket backlog.
++ * @param localBindAddress TODO
++ * @param logEventInput
++ * the log even input
++ * @throws IOException
++ * if an I/O error occurs when opening the socket.
++ * @since 2.7
++ */
++ @SuppressWarnings("resource")
++ public TcpSocketServer(final int port, final int backlog, final InetAddress localBindAddress, final LogEventBridge<T> logEventInput) throws IOException {
++ this(port, logEventInput, new ServerSocket(port, backlog, localBindAddress));
++ }
++
++ /**
++ * Constructor.
++ *
++ * @param port
++ * to listen.
++ * @param logEventInput
++ * the log even input
++ * @throws IOException
++ * if an I/O error occurs when opening the socket.
++ */
++ public TcpSocketServer(final int port, final LogEventBridge<T> logEventInput) throws IOException {
++ this(port, logEventInput, extracted(port));
++ }
++
++ private static ServerSocket extracted(final int port) throws IOException {
++ return new ServerSocket(port);
++ }
++
++ /**
++ * Constructor.
++ *
++ * @param port
++ * to listen.
++ * @param logEventInput
++ * the log even input
++ * @param serverSocket
++ * the socket server
++ * @throws IOException
++ * if an I/O error occurs when opening the socket.
++ */
++ public TcpSocketServer(final int port, final LogEventBridge<T> logEventInput, final ServerSocket serverSocket)
++ throws IOException {
++ super(port, logEventInput);
++ this.serverSocket = serverSocket;
++ }
++
++ /**
++ * Accept incoming events and processes them.
++ */
++ @Override
++ public void run() {
++ final EntryMessage entry = logger.traceEntry();
++ while (isActive()) {
++ if (serverSocket.isClosed()) {
++ return;
++ }
++ try {
++ // Accept incoming connections.
++ logger.debug("Listening for a connection {}...", serverSocket);
++ final Socket clientSocket = serverSocket.accept();
++ logger.debug("Acepted connection on {}...", serverSocket);
++ logger.debug("Socket accepted: {}", clientSocket);
++ clientSocket.setSoLinger(true, 0);
++
++ // accept() will block until a client connects to the server.
++ // If execution reaches this point, then it means that a client
++ // socket has been accepted.
++
++ final SocketHandler handler = new SocketHandler(clientSocket);
++ handlers.put(Long.valueOf(handler.getId()), handler);
++ handler.start();
++ } catch (final IOException e) {
++ if (serverSocket.isClosed()) {
++ // OK we're done.
++ logger.traceExit(entry);
++ return;
++ }
++ logger.error("Exception encountered on accept. Ignoring. Stack trace :", e);
++ }
++ }
++ for (final Map.Entry<Long, SocketHandler> handlerEntry : handlers.entrySet()) {
++ final SocketHandler handler = handlerEntry.getValue();
++ handler.shutdown();
++ try {
++ handler.join();
++ } catch (final InterruptedException ignored) {
++ // Ignore the exception
++ }
++ }
++ logger.traceExit(entry);
++ }
++
++ /**
++ * Shutdown the server.
++ *
++ * @throws IOException if the server socket could not be closed
++ */
++ @Override
++ public void shutdown() throws IOException {
++ final EntryMessage entry = logger.traceEntry();
++ setActive(false);
++ Thread.currentThread().interrupt();
++ serverSocket.close();
++ logger.traceExit(entry);
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/UdpSocketServer.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/UdpSocketServer.java
index 0000000,0000000..a2bac17
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/UdpSocketServer.java
@@@ -1,0 -1,0 +1,169 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.ByteArrayInputStream;
++import java.io.EOFException;
++import java.io.IOException;
++import java.io.InputStream;
++import java.io.ObjectInputStream;
++import java.io.OptionalDataException;
++import java.net.DatagramPacket;
++import java.net.DatagramSocket;
++
++import org.apache.logging.log4j.core.config.ConfigurationFactory;
++import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
++
++/**
++ * Listens for Log4j events on a datagram socket and passes them on to Log4j.
++ *
++ * @param <T>
++ * The kind of input stream read
++ * @see #main(String[])
++ */
++public class UdpSocketServer<T extends InputStream> extends AbstractSocketServer<T> {
++
++ /**
++ * Creates a socket server that reads JSON log events.
++ *
++ * @param port
++ * the port to listen
++ * @return a new a socket server
++ * @throws IOException
++ * if an I/O error occurs when opening the socket.
++ */
++ public static UdpSocketServer<InputStream> createJsonSocketServer(final int port) throws IOException {
++ return new UdpSocketServer<>(port, new JsonInputStreamLogEventBridge());
++ }
++
++ /**
++ * Creates a socket server that reads serialized log events.
++ *
++ * @param port
++ * the port to listen
++ * @return a new a socket server
++ * @throws IOException
++ * if an I/O error occurs when opening the socket.
++ */
++ public static UdpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port) throws IOException {
++ return new UdpSocketServer<>(port, new ObjectInputStreamLogEventBridge());
++ }
++
++ /**
++ * Creates a socket server that reads XML log events.
++ *
++ * @param port
++ * the port to listen
++ * @return a new a socket server
++ * @throws IOException
++ * if an I/O error occurs when opening the socket.
++ */
++ public static UdpSocketServer<InputStream> createXmlSocketServer(final int port) throws IOException {
++ return new UdpSocketServer<>(port, new XmlInputStreamLogEventBridge());
++ }
++
++ /**
++ * Main startup for the server. Run with "--help" for to print command line help on the console.
++ *
++ * @param args
++ * The command line arguments.
++ * @throws Exception
++ * if an error occurs.
++ */
++ public static void main(final String[] args) throws Exception {
++ final CommandLineArguments cla = BasicCommandLineArguments.parseCommandLine(args, UdpSocketServer.class, new CommandLineArguments());
++ if (cla.isHelp()) {
++ return;
++ }
++ if (cla.getConfigLocation() != null) {
++ ConfigurationFactory.setConfigurationFactory(new ServerConfigurationFactory(cla.getConfigLocation()));
++ }
++ final UdpSocketServer<ObjectInputStream> socketServer = UdpSocketServer
++ .createSerializedSocketServer(cla.getPort());
++ final Thread serverThread = socketServer.startNewThread();
++ if (cla.isInteractive()) {
++ socketServer.awaitTermination(serverThread);
++ }
++ }
++
++ private final DatagramSocket datagramSocket;
++
++ // max size so we only have to deal with one packet
++ private final int maxBufferSize = 1024 * 65 + 1024;
++
++ /**
++ * Constructor.
++ *
++ * @param port
++ * to listen on.
++ * @param logEventInput
++ * @throws IOException
++ * If an error occurs.
++ */
++ public UdpSocketServer(final int port, final LogEventBridge<T> logEventInput) throws IOException {
++ super(port, logEventInput);
++ this.datagramSocket = new DatagramSocket(port);
++ }
++
++ /**
++ * Accept incoming events and processes them.
++ */
++ @Override
++ public void run() {
++ while (isActive()) {
++ if (datagramSocket.isClosed()) {
++ // OK we're done.
++ return;
++ }
++ try {
++ final byte[] buf = new byte[maxBufferSize];
++ final DatagramPacket packet = new DatagramPacket(buf, buf.length);
++ datagramSocket.receive(packet);
++ final ByteArrayInputStream bais = new ByteArrayInputStream(packet.getData(), packet.getOffset(), packet.getLength());
++ logEventInput.logEvents(logEventInput.wrapStream(bais), this);
++ } catch (final OptionalDataException e) {
++ if (datagramSocket.isClosed()) {
++ // OK we're done.
++ return;
++ }
++ logger.error("OptionalDataException eof=" + e.eof + " length=" + e.length, e);
++ } catch (final EOFException e) {
++ if (datagramSocket.isClosed()) {
++ // OK we're done.
++ return;
++ }
++ logger.info("EOF encountered");
++ } catch (final IOException e) {
++ if (datagramSocket.isClosed()) {
++ // OK we're done.
++ return;
++ }
++ logger.error("Exception encountered on accept. Ignoring. Stack Trace :", e);
++ }
++ }
++ }
++
++ /**
++ * Shutdown the server.
++ */
++ @Override
++ public void shutdown() {
++ this.setActive(false);
++ Thread.currentThread().interrupt();
++ datagramSocket.close();
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/XmlInputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/XmlInputStreamLogEventBridge.java
index 0000000,0000000..683ae07
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/XmlInputStreamLogEventBridge.java
@@@ -1,0 -1,0 +1,54 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++package org.apache.logging.log4j.server;
++
++import java.io.InputStream;
++import java.nio.charset.Charset;
++
++import org.apache.logging.log4j.core.LogEvent;
++import org.apache.logging.log4j.core.jackson.Log4jXmlObjectMapper;
++
++/**
++ * Reads and logs {@link LogEvent}s from an {@link InputStream}.
++ */
++public class XmlInputStreamLogEventBridge extends InputStreamLogEventBridge {
++
++ private static final String EVENT_END = "</Event>";
++ private static final String EVENT_START_NS_N = "<Event>";
++ private static final String EVENT_START_NS_Y = "<Event ";
++
++ public XmlInputStreamLogEventBridge() {
++ this(1024, Charset.defaultCharset());
++ }
++
++ public XmlInputStreamLogEventBridge(final int bufferSize, final Charset charset) {
++ super(new Log4jXmlObjectMapper(), bufferSize, charset, EVENT_END);
++ }
++
++ @Override
++ protected int[] getEventIndices(final String text, final int beginIndex) {
++ int start = text.indexOf(EVENT_START_NS_Y, beginIndex);
++ int startLen = EVENT_START_NS_Y.length();
++ if (start < 0) {
++ start = text.indexOf(EVENT_START_NS_N, beginIndex);
++ startLen = EVENT_START_NS_N.length();
++ }
++ final int end = start < 0 ? -1 : text.indexOf(EVENT_END, start + startLen);
++ return new int[] { start, end };
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/AbstractJmsReceiver.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/AbstractJmsReceiver.java
index 0000000,0000000..373d31c
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/AbstractJmsReceiver.java
@@@ -1,0 -1,0 +1,48 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++package org.apache.logging.log4j.server.mom.jms;
++
++import org.apache.logging.log4j.server.JmsServer;
++
++/**
++ * Common JMS server functionality.
++ *
++ * @since 2.6
++ */
++public abstract class AbstractJmsReceiver {
++
++ /**
++ * Prints out usage information to {@linkplain System#err standard error}.
++ */
++ protected abstract void usage();
++
++ /**
++ * Executes a JmsServer with the given command line arguments.
++ *
++ * @param args command line arguments
++ * @throws Exception
++ */
++ protected void doMain(final String... args) throws Exception {
++ if (args.length != 4) {
++ usage();
++ System.exit(1);
++ }
++ final JmsServer server = new JmsServer(args[0], args[1], args[2], args[3]);
++ server.run();
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/JmsQueueReceiver.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/JmsQueueReceiver.java
index 0000000,0000000..a7f75ec
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/JmsQueueReceiver.java
@@@ -1,0 -1,0 +1,46 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++package org.apache.logging.log4j.server.mom.jms;
++
++/**
++ * Receives Log Events over a JMS Queue. This implementation expects that all messages will
++ * contain a serialized LogEvent.
++ */
++public class JmsQueueReceiver extends AbstractJmsReceiver {
++
++ private JmsQueueReceiver() {
++ }
++
++ /**
++ * Main startup for the receiver.
++ *
++ * @param args The command line arguments.
++ * @throws Exception if an error occurs.
++ */
++ public static void main(final String[] args) throws Exception {
++ final JmsQueueReceiver receiver = new JmsQueueReceiver();
++ receiver.doMain(args);
++ }
++
++ @Override
++ protected void usage() {
++ System.err.println("Wrong number of arguments.");
++ System.err.println("Usage: java " + JmsQueueReceiver.class.getName()
++ + " QueueConnectionFactoryBindingName QueueBindingName username password");
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/JmsTopicReceiver.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/JmsTopicReceiver.java
index 0000000,0000000..21828d7
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/JmsTopicReceiver.java
@@@ -1,0 -1,0 +1,46 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++package org.apache.logging.log4j.server.mom.jms;
++
++/**
++ * Receives Topic messages that contain LogEvents. This implementation expects that all messages
++ * are serialized log events.
++ */
++public class JmsTopicReceiver extends AbstractJmsReceiver {
++
++ private JmsTopicReceiver() {
++ }
++
++ /**
++ * Main startup for the receiver.
++ *
++ * @param args The command line arguments.
++ * @throws Exception if an error occurs.
++ */
++ public static void main(final String[] args) throws Exception {
++ final JmsTopicReceiver receiver = new JmsTopicReceiver();
++ receiver.doMain(args);
++ }
++
++ @Override
++ protected void usage() {
++ System.err.println("Wrong number of arguments.");
++ System.err.println("Usage: java " + JmsTopicReceiver.class.getName()
++ + " TopicConnectionFactoryBindingName TopicBindingName username password");
++ }
++}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/package-info.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/package-info.java
index 0000000,0000000..dd9c90e
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/mom/jms/package-info.java
@@@ -1,0 -1,0 +1,26 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++/**
++ * Supporting network code for JMS appenders.
++ *
++ * <p>Note that you can use JmsQueueReceiver or JmsTopicReceiver as executable main classes to receive log events over
++ * JMS (sent via the appropriate JMS appender) that can be subsequently logged according to the configuration given to
++ * the running process. Of course, use of these classes as standalone executables are entirely optional and can
++ * be used directly in your application (e.g., through your Spring {@code beans.xml} configuration).</p>
++ */
++package org.apache.logging.log4j.server.mom.jms;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/main/java/org/apache/logging/log4j/server/package-info.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/package-info.java
index 0000000,0000000..c446a9d
new file mode 100644
--- /dev/null
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/package-info.java
@@@ -1,0 -1,0 +1,24 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache license, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the license for the specific language governing permissions and
++ * limitations under the license.
++ */
++
++/**
++ * Standalone server classes for consuming log events over a network. Each of the various servers should be used with
++ * another Log4j configuration to handle incoming {@link org.apache.logging.log4j.core.LogEvent}s. It is recommended
++ * to consider using the <a href="../../../../../../../../../manual/appenders.html#FlumeAppender">Flume Appender</a>
++ * for highly reliable networked logging.
++ */
++package org.apache.logging.log4j.server;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b77b7d03/log4j-server/src/site/markdown/index.md
----------------------------------------------------------------------
diff --cc log4j-server/src/site/markdown/index.md
index b66e935,0000000..b3d96ba
mode 100644,000000..100644
--- a/log4j-server/src/site/markdown/index.md
+++ b/log4j-server/src/site/markdown/index.md
@@@ -1,29 -1,0 +1,30 @@@
+<!-- vim: set syn=markdown : -->
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+# Log4j Server components
+
+## Log4j Server components
+
++Standalone server classes for consuming log events over a network. Each of the various servers should be used with
++another Log4j configuration to handle incoming log events. It is recommended to consider using the
++[Flume Appender](../manual/appenders.html#FlumeAppender) for highly reliable networked logging.
+
+## Requirements
+
+The Log4j Server components requires the Log4j 2 API and core. This component was introduced in Log4j 2.8.2,
- before it was part of log4j-core. For more information, see [Runtime Dependencies](../runtime-dependencies.html).
-
- ## Usage
++before it was part of log4j-core. For more information, see [Runtime Dependencies](../manual/runtime-dependencies.html).
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Ralph Goers <ra...@dslextreme.com>.
Maybe, but if it is large enough I would just migrate it from svn to its own git repo.
Ralph
> On Apr 10, 2017, at 9:05 AM, Gary Gregory <ga...@gmail.com> wrote:
>
> Is this where a Chainsaw refresh would live?
>
> Gary
>
> On Apr 10, 2017 9:01 AM, "Ralph Goers" <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> I’m fine with that. I just don’t want more modules in the main project.
>
> Ralph
>
>> On Apr 10, 2017, at 8:56 AM, Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>> wrote:
>>
>> The whole point of this is to get the server components out of log4j-core, so we need to create a new module. Maybe this new module can be moved to log4j2-tools repo.
>>
>> On Mon, Apr 10, 2017 at 5:48 PM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
>> I created a new git repo for log4j2-tools. We should not create any more modules if we can avoid it.
>>
>> Ralph
>>
>>> On Apr 10, 2017, at 7:28 AM, Remko Popma <remko.popma@gmail.com <ma...@gmail.com>> wrote:
>>>
>>> I guess this is a matter of preference but we already have a lot of modules.
>>> Having one for all standalone applications makes it easier for our users to find things.
>>>
>>> On Mon, Apr 10, 2017 at 11:24 PM, Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>> wrote:
>>> Wouldn't it be better to have one for server and another for the other tools?
>>>
>>> On Mon, Apr 10, 2017 at 4:23 PM, Remko Popma <remko.popma@gmail.com <ma...@gmail.com>> wrote:
>>> I thought we were going to name this module log4j-tools instead of log4j-server, so it can host all our standalone apps?
>>>
>>> On Mon, Apr 10, 2017 at 11:11 PM, <mikes@apache.org <ma...@apache.org>> wrote:
>>> Update BOM
>>>
>>>
>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fea17ad6>
>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6>
>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6>
>>>
>>> Branch: refs/heads/master
>>> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
>>> Parents: 1051081
>>> Author: Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>>
>>> Authored: Mon Apr 10 16:11:24 2017 +0200
>>> Committer: Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>>
>>> Committed: Mon Apr 10 16:11:24 2017 +0200
>>>
>>> ----------------------------------------------------------------------
>>> log4j-bom/pom.xml | 6 ++++++
>>> 1 file changed, 6 insertions(+)
>>> ----------------------------------------------------------------------
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fea17ad6/log4j-bom/pom.xml <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fea17ad6/log4j-bom/pom.xml>
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
>>> index 920f6a0..382f16e 100644
>>> --- a/log4j-bom/pom.xml
>>> +++ b/log4j-bom/pom.xml
>>> @@ -96,6 +96,12 @@
>>> <artifactId>log4j-iostreams</artifactId>
>>> <version>${project.version}</version>
>>> </dependency>
>>> + <!-- Server components -->
>>> + <dependency>
>>> + <groupId>org.apache.logging.log4j</groupId>
>>> + <artifactId>log4j-server</artifactId>
>>> + <version>${project.version}</version>
>>> + </dependency>
>>> <!-- java.util.logging adapter -->
>>> <dependency>
>>> <groupId>org.apache.logging.log4j</groupId>
>>>
>>>
>>>
>>>
>>>
>>> --
>>>
>>>
>>> Mikael Ståldal
>>> Senior software developer
>>>
>>> Magine TV
>>> mikael.staldal@magine.com <ma...@magine.com>
>>> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com <http://www.magine.com/>
>>>
>>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply email.
>>>
>>
>>
>>
>>
>> --
>>
>>
>> Mikael Ståldal
>> Senior software developer
>>
>> Magine TV
>> mikael.staldal@magine.com <ma...@magine.com>
>> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com <http://www.magine.com/>
>>
>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply email.
>
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Gary Gregory <ga...@gmail.com>.
Is this where a Chainsaw refresh would live?
Gary
On Apr 10, 2017 9:01 AM, "Ralph Goers" <ra...@dslextreme.com> wrote:
> I’m fine with that. I just don’t want more modules in the main project.
>
> Ralph
>
> On Apr 10, 2017, at 8:56 AM, Mikael Ståldal <mi...@magine.com>
> wrote:
>
> The whole point of this is to get the server components out of log4j-core,
> so we need to create a new module. Maybe this new module can be moved to
> log4j2-tools repo.
>
> On Mon, Apr 10, 2017 at 5:48 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> I created a new git repo for log4j2-tools. We should not create any more
>> modules if we can avoid it.
>>
>> Ralph
>>
>> On Apr 10, 2017, at 7:28 AM, Remko Popma <re...@gmail.com> wrote:
>>
>> I guess this is a matter of preference but we already have a lot of
>> modules.
>> Having one for all standalone applications makes it easier for our users
>> to find things.
>>
>> On Mon, Apr 10, 2017 at 11:24 PM, Mikael Ståldal <
>> mikael.staldal@magine.com> wrote:
>>
>>> Wouldn't it be better to have one for server and another for the other
>>> tools?
>>>
>>> On Mon, Apr 10, 2017 at 4:23 PM, Remko Popma <re...@gmail.com>
>>> wrote:
>>>
>>>> I thought we were going to name this module log4j-tools instead of
>>>> log4j-server, so it can host all our standalone apps?
>>>>
>>>> On Mon, Apr 10, 2017 at 11:11 PM, <mi...@apache.org> wrote:
>>>>
>>>>> Update BOM
>>>>>
>>>>>
>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit
>>>>> /fea17ad6
>>>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f
>>>>> ea17ad6
>>>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f
>>>>> ea17ad6
>>>>>
>>>>> Branch: refs/heads/master
>>>>> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
>>>>> Parents: 1051081
>>>>> Author: Mikael Ståldal <mi...@magine.com>
>>>>> Authored: Mon Apr 10 16:11:24 2017 +0200
>>>>> Committer: Mikael Ståldal <mi...@magine.com>
>>>>> Committed: Mon Apr 10 16:11:24 2017 +0200
>>>>>
>>>>> ----------------------------------------------------------------------
>>>>> log4j-bom/pom.xml | 6 ++++++
>>>>> 1 file changed, 6 insertions(+)
>>>>> ----------------------------------------------------------------------
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>>>> ea17ad6/log4j-bom/pom.xml
>>>>> ----------------------------------------------------------------------
>>>>> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
>>>>> index 920f6a0..382f16e 100644
>>>>> --- a/log4j-bom/pom.xml
>>>>> +++ b/log4j-bom/pom.xml
>>>>> @@ -96,6 +96,12 @@
>>>>> <artifactId>log4j-iostreams</artifactId>
>>>>> <version>${project.version}</version>
>>>>> </dependency>
>>>>> + <!-- Server components -->
>>>>> + <dependency>
>>>>> + <groupId>org.apache.logging.log4j</groupId>
>>>>> + <artifactId>log4j-server</artifactId>
>>>>> + <version>${project.version}</version>
>>>>> + </dependency>
>>>>> <!-- java.util.logging adapter -->
>>>>> <dependency>
>>>>> <groupId>org.apache.logging.log4j</groupId>
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>
>>
>>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>
>
>
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Ralph Goers <ra...@dslextreme.com>.
I’m fine with that. I just don’t want more modules in the main project.
Ralph
> On Apr 10, 2017, at 8:56 AM, Mikael Ståldal <mi...@magine.com> wrote:
>
> The whole point of this is to get the server components out of log4j-core, so we need to create a new module. Maybe this new module can be moved to log4j2-tools repo.
>
> On Mon, Apr 10, 2017 at 5:48 PM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> I created a new git repo for log4j2-tools. We should not create any more modules if we can avoid it.
>
> Ralph
>
>> On Apr 10, 2017, at 7:28 AM, Remko Popma <remko.popma@gmail.com <ma...@gmail.com>> wrote:
>>
>> I guess this is a matter of preference but we already have a lot of modules.
>> Having one for all standalone applications makes it easier for our users to find things.
>>
>> On Mon, Apr 10, 2017 at 11:24 PM, Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>> wrote:
>> Wouldn't it be better to have one for server and another for the other tools?
>>
>> On Mon, Apr 10, 2017 at 4:23 PM, Remko Popma <remko.popma@gmail.com <ma...@gmail.com>> wrote:
>> I thought we were going to name this module log4j-tools instead of log4j-server, so it can host all our standalone apps?
>>
>> On Mon, Apr 10, 2017 at 11:11 PM, <mikes@apache.org <ma...@apache.org>> wrote:
>> Update BOM
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fea17ad6>
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6>
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6>
>>
>> Branch: refs/heads/master
>> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
>> Parents: 1051081
>> Author: Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>>
>> Authored: Mon Apr 10 16:11:24 2017 +0200
>> Committer: Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>>
>> Committed: Mon Apr 10 16:11:24 2017 +0200
>>
>> ----------------------------------------------------------------------
>> log4j-bom/pom.xml | 6 ++++++
>> 1 file changed, 6 insertions(+)
>> ----------------------------------------------------------------------
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fea17ad6/log4j-bom/pom.xml <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fea17ad6/log4j-bom/pom.xml>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
>> index 920f6a0..382f16e 100644
>> --- a/log4j-bom/pom.xml
>> +++ b/log4j-bom/pom.xml
>> @@ -96,6 +96,12 @@
>> <artifactId>log4j-iostreams</artifactId>
>> <version>${project.version}</version>
>> </dependency>
>> + <!-- Server components -->
>> + <dependency>
>> + <groupId>org.apache.logging.log4j</groupId>
>> + <artifactId>log4j-server</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> <!-- java.util.logging adapter -->
>> <dependency>
>> <groupId>org.apache.logging.log4j</groupId>
>>
>>
>>
>>
>>
>> --
>>
>>
>> Mikael Ståldal
>> Senior software developer
>>
>> Magine TV
>> mikael.staldal@magine.com <ma...@magine.com>
>> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com <http://www.magine.com/>
>>
>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply email.
>>
>
>
>
>
> --
>
>
> Mikael Ståldal
> Senior software developer
>
> Magine TV
> mikael.staldal@magine.com <ma...@magine.com>
> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com <http://www.magine.com/>
>
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply email.
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Mikael Ståldal <mi...@magine.com>.
The whole point of this is to get the server components out of log4j-core,
so we need to create a new module. Maybe this new module can be moved to
log4j2-tools repo.
On Mon, Apr 10, 2017 at 5:48 PM, Ralph Goers <ra...@dslextreme.com>
wrote:
> I created a new git repo for log4j2-tools. We should not create any more
> modules if we can avoid it.
>
> Ralph
>
> On Apr 10, 2017, at 7:28 AM, Remko Popma <re...@gmail.com> wrote:
>
> I guess this is a matter of preference but we already have a lot of
> modules.
> Having one for all standalone applications makes it easier for our users
> to find things.
>
> On Mon, Apr 10, 2017 at 11:24 PM, Mikael Ståldal <
> mikael.staldal@magine.com> wrote:
>
>> Wouldn't it be better to have one for server and another for the other
>> tools?
>>
>> On Mon, Apr 10, 2017 at 4:23 PM, Remko Popma <re...@gmail.com>
>> wrote:
>>
>>> I thought we were going to name this module log4j-tools instead of
>>> log4j-server, so it can host all our standalone apps?
>>>
>>> On Mon, Apr 10, 2017 at 11:11 PM, <mi...@apache.org> wrote:
>>>
>>>> Update BOM
>>>>
>>>>
>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit
>>>> /fea17ad6
>>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f
>>>> ea17ad6
>>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f
>>>> ea17ad6
>>>>
>>>> Branch: refs/heads/master
>>>> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
>>>> Parents: 1051081
>>>> Author: Mikael Ståldal <mi...@magine.com>
>>>> Authored: Mon Apr 10 16:11:24 2017 +0200
>>>> Committer: Mikael Ståldal <mi...@magine.com>
>>>> Committed: Mon Apr 10 16:11:24 2017 +0200
>>>>
>>>> ----------------------------------------------------------------------
>>>> log4j-bom/pom.xml | 6 ++++++
>>>> 1 file changed, 6 insertions(+)
>>>> ----------------------------------------------------------------------
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>>> ea17ad6/log4j-bom/pom.xml
>>>> ----------------------------------------------------------------------
>>>> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
>>>> index 920f6a0..382f16e 100644
>>>> --- a/log4j-bom/pom.xml
>>>> +++ b/log4j-bom/pom.xml
>>>> @@ -96,6 +96,12 @@
>>>> <artifactId>log4j-iostreams</artifactId>
>>>> <version>${project.version}</version>
>>>> </dependency>
>>>> + <!-- Server components -->
>>>> + <dependency>
>>>> + <groupId>org.apache.logging.log4j</groupId>
>>>> + <artifactId>log4j-server</artifactId>
>>>> + <version>${project.version}</version>
>>>> + </dependency>
>>>> <!-- java.util.logging adapter -->
>>>> <dependency>
>>>> <groupId>org.apache.logging.log4j</groupId>
>>>>
>>>>
>>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>
>
>
--
[image: MagineTV]
*Mikael Ståldal*
Senior software developer
*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Remko Popma <re...@gmail.com>.
Thanks!!
Sent from my iPhone
> On Apr 11, 2017, at 18:09, Mikael Ståldal <mi...@magine.com> wrote:
>
> OK, moved now.
>
>> On Mon, Apr 10, 2017 at 6:15 PM, Ralph Goers <ra...@dslextreme.com> wrote:
>> Yes, that is the repo. Initially, all it needs is a parent pom that references the module you created. We can move other stuff in later. It will need a web site of some kind but we can also worry about that later.
>>
>> Ralph
>>
>>> On Apr 10, 2017, at 9:11 AM, Mikael Ståldal <mi...@magine.com> wrote:
>>>
>>> Is it this repo? git://git.apache.org/logging-log4j-tools.git
>>>
>>> It is currently empty (except two text files). I don't feel confident to do the initial setup of the repository.
>>>
>>>> On Mon, Apr 10, 2017 at 5:48 PM, Ralph Goers <ra...@dslextreme.com> wrote:
>>>> I created a new git repo for log4j2-tools. We should not create any more modules if we can avoid it.
>>>>
>>>> Ralph
>>>>
>>>>> On Apr 10, 2017, at 7:28 AM, Remko Popma <re...@gmail.com> wrote:
>>>>>
>>>>> I guess this is a matter of preference but we already have a lot of modules.
>>>>> Having one for all standalone applications makes it easier for our users to find things.
>>>>>
>>>>>> On Mon, Apr 10, 2017 at 11:24 PM, Mikael Ståldal <mi...@magine.com> wrote:
>>>>>> Wouldn't it be better to have one for server and another for the other tools?
>>>>>>
>>>>>>> On Mon, Apr 10, 2017 at 4:23 PM, Remko Popma <re...@gmail.com> wrote:
>>>>>>> I thought we were going to name this module log4j-tools instead of log4j-server, so it can host all our standalone apps?
>>>>>>>
>>>>>>>> On Mon, Apr 10, 2017 at 11:11 PM, <mi...@apache.org> wrote:
>>>>>>>> Update BOM
>>>>>>>>
>>>>>>>>
>>>>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>>>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fea17ad6
>>>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6
>>>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6
>>>>>>>>
>>>>>>>> Branch: refs/heads/master
>>>>>>>> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
>>>>>>>> Parents: 1051081
>>>>>>>> Author: Mikael Ståldal <mi...@magine.com>
>>>>>>>> Authored: Mon Apr 10 16:11:24 2017 +0200
>>>>>>>> Committer: Mikael Ståldal <mi...@magine.com>
>>>>>>>> Committed: Mon Apr 10 16:11:24 2017 +0200
>>>>>>>>
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> log4j-bom/pom.xml | 6 ++++++
>>>>>>>> 1 file changed, 6 insertions(+)
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>>
>>>>>>>>
>>>>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fea17ad6/log4j-bom/pom.xml
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
>>>>>>>> index 920f6a0..382f16e 100644
>>>>>>>> --- a/log4j-bom/pom.xml
>>>>>>>> +++ b/log4j-bom/pom.xml
>>>>>>>> @@ -96,6 +96,12 @@
>>>>>>>> <artifactId>log4j-iostreams</artifactId>
>>>>>>>> <version>${project.version}</version>
>>>>>>>> </dependency>
>>>>>>>> + <!-- Server components -->
>>>>>>>> + <dependency>
>>>>>>>> + <groupId>org.apache.logging.log4j</groupId>
>>>>>>>> + <artifactId>log4j-server</artifactId>
>>>>>>>> + <version>${project.version}</version>
>>>>>>>> + </dependency>
>>>>>>>> <!-- java.util.logging adapter -->
>>>>>>>> <dependency>
>>>>>>>> <groupId>org.apache.logging.log4j</groupId>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>>
>>>>>> Mikael Ståldal
>>>>>> Senior software developer
>>>>>>
>>>>>> Magine TV
>>>>>> mikael.staldal@magine.com
>>>>>> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>>>>>>
>>>>>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>>>>>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,
>>>>>> you should destroy this message and kindly notify the sender by reply email.
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>>
>>>
>>> Mikael Ståldal
>>> Senior software developer
>>>
>>> Magine TV
>>> mikael.staldal@magine.com
>>> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply email.
>>
>
>
>
> --
>
>
> Mikael Ståldal
> Senior software developer
>
> Magine TV
> mikael.staldal@magine.com
> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply email.
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Mikael Ståldal <mi...@magine.com>.
OK, moved now.
On Mon, Apr 10, 2017 at 6:15 PM, Ralph Goers <ra...@dslextreme.com>
wrote:
> Yes, that is the repo. Initially, all it needs is a parent pom that
> references the module you created. We can move other stuff in later. It
> will need a web site of some kind but we can also worry about that later.
>
> Ralph
>
> On Apr 10, 2017, at 9:11 AM, Mikael Ståldal <mi...@magine.com>
> wrote:
>
> Is it this repo? git://git.apache.org/logging-log4j-tools.git
>
> It is currently empty (except two text files). I don't feel confident to
> do the initial setup of the repository.
>
> On Mon, Apr 10, 2017 at 5:48 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> I created a new git repo for log4j2-tools. We should not create any more
>> modules if we can avoid it.
>>
>> Ralph
>>
>> On Apr 10, 2017, at 7:28 AM, Remko Popma <re...@gmail.com> wrote:
>>
>> I guess this is a matter of preference but we already have a lot of
>> modules.
>> Having one for all standalone applications makes it easier for our users
>> to find things.
>>
>> On Mon, Apr 10, 2017 at 11:24 PM, Mikael Ståldal <
>> mikael.staldal@magine.com> wrote:
>>
>>> Wouldn't it be better to have one for server and another for the other
>>> tools?
>>>
>>> On Mon, Apr 10, 2017 at 4:23 PM, Remko Popma <re...@gmail.com>
>>> wrote:
>>>
>>>> I thought we were going to name this module log4j-tools instead of
>>>> log4j-server, so it can host all our standalone apps?
>>>>
>>>> On Mon, Apr 10, 2017 at 11:11 PM, <mi...@apache.org> wrote:
>>>>
>>>>> Update BOM
>>>>>
>>>>>
>>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit
>>>>> /fea17ad6
>>>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f
>>>>> ea17ad6
>>>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f
>>>>> ea17ad6
>>>>>
>>>>> Branch: refs/heads/master
>>>>> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
>>>>> Parents: 1051081
>>>>> Author: Mikael Ståldal <mi...@magine.com>
>>>>> Authored: Mon Apr 10 16:11:24 2017 +0200
>>>>> Committer: Mikael Ståldal <mi...@magine.com>
>>>>> Committed: Mon Apr 10 16:11:24 2017 +0200
>>>>>
>>>>> ----------------------------------------------------------------------
>>>>> log4j-bom/pom.xml | 6 ++++++
>>>>> 1 file changed, 6 insertions(+)
>>>>> ----------------------------------------------------------------------
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>>>> ea17ad6/log4j-bom/pom.xml
>>>>> ----------------------------------------------------------------------
>>>>> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
>>>>> index 920f6a0..382f16e 100644
>>>>> --- a/log4j-bom/pom.xml
>>>>> +++ b/log4j-bom/pom.xml
>>>>> @@ -96,6 +96,12 @@
>>>>> <artifactId>log4j-iostreams</artifactId>
>>>>> <version>${project.version}</version>
>>>>> </dependency>
>>>>> + <!-- Server components -->
>>>>> + <dependency>
>>>>> + <groupId>org.apache.logging.log4j</groupId>
>>>>> + <artifactId>log4j-server</artifactId>
>>>>> + <version>${project.version}</version>
>>>>> + </dependency>
>>>>> <!-- java.util.logging adapter -->
>>>>> <dependency>
>>>>> <groupId>org.apache.logging.log4j</groupId>
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>
>>
>>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>
>
>
--
[image: MagineTV]
*Mikael Ståldal*
Senior software developer
*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Ralph Goers <ra...@dslextreme.com>.
Yes, that is the repo. Initially, all it needs is a parent pom that references the module you created. We can move other stuff in later. It will need a web site of some kind but we can also worry about that later.
Ralph
> On Apr 10, 2017, at 9:11 AM, Mikael Ståldal <mi...@magine.com> wrote:
>
> Is it this repo? git://git.apache.org/logging-log4j-tools.git <http://git.apache.org/logging-log4j-tools.git>
>
> It is currently empty (except two text files). I don't feel confident to do the initial setup of the repository.
>
> On Mon, Apr 10, 2017 at 5:48 PM, Ralph Goers <ralph.goers@dslextreme.com <ma...@dslextreme.com>> wrote:
> I created a new git repo for log4j2-tools. We should not create any more modules if we can avoid it.
>
> Ralph
>
>> On Apr 10, 2017, at 7:28 AM, Remko Popma <remko.popma@gmail.com <ma...@gmail.com>> wrote:
>>
>> I guess this is a matter of preference but we already have a lot of modules.
>> Having one for all standalone applications makes it easier for our users to find things.
>>
>> On Mon, Apr 10, 2017 at 11:24 PM, Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>> wrote:
>> Wouldn't it be better to have one for server and another for the other tools?
>>
>> On Mon, Apr 10, 2017 at 4:23 PM, Remko Popma <remko.popma@gmail.com <ma...@gmail.com>> wrote:
>> I thought we were going to name this module log4j-tools instead of log4j-server, so it can host all our standalone apps?
>>
>> On Mon, Apr 10, 2017 at 11:11 PM, <mikes@apache.org <ma...@apache.org>> wrote:
>> Update BOM
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fea17ad6>
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6>
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6>
>>
>> Branch: refs/heads/master
>> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
>> Parents: 1051081
>> Author: Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>>
>> Authored: Mon Apr 10 16:11:24 2017 +0200
>> Committer: Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>>
>> Committed: Mon Apr 10 16:11:24 2017 +0200
>>
>> ----------------------------------------------------------------------
>> log4j-bom/pom.xml | 6 ++++++
>> 1 file changed, 6 insertions(+)
>> ----------------------------------------------------------------------
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fea17ad6/log4j-bom/pom.xml <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fea17ad6/log4j-bom/pom.xml>
>> ----------------------------------------------------------------------
>> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
>> index 920f6a0..382f16e 100644
>> --- a/log4j-bom/pom.xml
>> +++ b/log4j-bom/pom.xml
>> @@ -96,6 +96,12 @@
>> <artifactId>log4j-iostreams</artifactId>
>> <version>${project.version}</version>
>> </dependency>
>> + <!-- Server components -->
>> + <dependency>
>> + <groupId>org.apache.logging.log4j</groupId>
>> + <artifactId>log4j-server</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> <!-- java.util.logging adapter -->
>> <dependency>
>> <groupId>org.apache.logging.log4j</groupId>
>>
>>
>>
>>
>>
>> --
>>
>>
>> Mikael Ståldal
>> Senior software developer
>>
>> Magine TV
>> mikael.staldal@magine.com <ma...@magine.com>
>> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com <http://www.magine.com/>
>>
>> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply email.
>>
>
>
>
>
> --
>
>
> Mikael Ståldal
> Senior software developer
>
> Magine TV
> mikael.staldal@magine.com <ma...@magine.com>
> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com <http://www.magine.com/>
>
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply email.
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Mikael Ståldal <mi...@magine.com>.
Is it this repo? git://git.apache.org/logging-log4j-tools.git
It is currently empty (except two text files). I don't feel confident to do
the initial setup of the repository.
On Mon, Apr 10, 2017 at 5:48 PM, Ralph Goers <ra...@dslextreme.com>
wrote:
> I created a new git repo for log4j2-tools. We should not create any more
> modules if we can avoid it.
>
> Ralph
>
> On Apr 10, 2017, at 7:28 AM, Remko Popma <re...@gmail.com> wrote:
>
> I guess this is a matter of preference but we already have a lot of
> modules.
> Having one for all standalone applications makes it easier for our users
> to find things.
>
> On Mon, Apr 10, 2017 at 11:24 PM, Mikael Ståldal <
> mikael.staldal@magine.com> wrote:
>
>> Wouldn't it be better to have one for server and another for the other
>> tools?
>>
>> On Mon, Apr 10, 2017 at 4:23 PM, Remko Popma <re...@gmail.com>
>> wrote:
>>
>>> I thought we were going to name this module log4j-tools instead of
>>> log4j-server, so it can host all our standalone apps?
>>>
>>> On Mon, Apr 10, 2017 at 11:11 PM, <mi...@apache.org> wrote:
>>>
>>>> Update BOM
>>>>
>>>>
>>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit
>>>> /fea17ad6
>>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f
>>>> ea17ad6
>>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f
>>>> ea17ad6
>>>>
>>>> Branch: refs/heads/master
>>>> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
>>>> Parents: 1051081
>>>> Author: Mikael Ståldal <mi...@magine.com>
>>>> Authored: Mon Apr 10 16:11:24 2017 +0200
>>>> Committer: Mikael Ståldal <mi...@magine.com>
>>>> Committed: Mon Apr 10 16:11:24 2017 +0200
>>>>
>>>> ----------------------------------------------------------------------
>>>> log4j-bom/pom.xml | 6 ++++++
>>>> 1 file changed, 6 insertions(+)
>>>> ----------------------------------------------------------------------
>>>>
>>>>
>>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>>> ea17ad6/log4j-bom/pom.xml
>>>> ----------------------------------------------------------------------
>>>> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
>>>> index 920f6a0..382f16e 100644
>>>> --- a/log4j-bom/pom.xml
>>>> +++ b/log4j-bom/pom.xml
>>>> @@ -96,6 +96,12 @@
>>>> <artifactId>log4j-iostreams</artifactId>
>>>> <version>${project.version}</version>
>>>> </dependency>
>>>> + <!-- Server components -->
>>>> + <dependency>
>>>> + <groupId>org.apache.logging.log4j</groupId>
>>>> + <artifactId>log4j-server</artifactId>
>>>> + <version>${project.version}</version>
>>>> + </dependency>
>>>> <!-- java.util.logging adapter -->
>>>> <dependency>
>>>> <groupId>org.apache.logging.log4j</groupId>
>>>>
>>>>
>>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>
>
>
--
[image: MagineTV]
*Mikael Ståldal*
Senior software developer
*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Ralph Goers <ra...@dslextreme.com>.
I created a new git repo for log4j2-tools. We should not create any more modules if we can avoid it.
Ralph
> On Apr 10, 2017, at 7:28 AM, Remko Popma <re...@gmail.com> wrote:
>
> I guess this is a matter of preference but we already have a lot of modules.
> Having one for all standalone applications makes it easier for our users to find things.
>
> On Mon, Apr 10, 2017 at 11:24 PM, Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>> wrote:
> Wouldn't it be better to have one for server and another for the other tools?
>
> On Mon, Apr 10, 2017 at 4:23 PM, Remko Popma <remko.popma@gmail.com <ma...@gmail.com>> wrote:
> I thought we were going to name this module log4j-tools instead of log4j-server, so it can host all our standalone apps?
>
> On Mon, Apr 10, 2017 at 11:11 PM, <mikes@apache.org <ma...@apache.org>> wrote:
> Update BOM
>
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo <http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo>
> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fea17ad6>
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6>
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6 <http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6>
>
> Branch: refs/heads/master
> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
> Parents: 1051081
> Author: Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>>
> Authored: Mon Apr 10 16:11:24 2017 +0200
> Committer: Mikael Ståldal <mikael.staldal@magine.com <ma...@magine.com>>
> Committed: Mon Apr 10 16:11:24 2017 +0200
>
> ----------------------------------------------------------------------
> log4j-bom/pom.xml | 6 ++++++
> 1 file changed, 6 insertions(+)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fea17ad6/log4j-bom/pom.xml <http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fea17ad6/log4j-bom/pom.xml>
> ----------------------------------------------------------------------
> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
> index 920f6a0..382f16e 100644
> --- a/log4j-bom/pom.xml
> +++ b/log4j-bom/pom.xml
> @@ -96,6 +96,12 @@
> <artifactId>log4j-iostreams</artifactId>
> <version>${project.version}</version>
> </dependency>
> + <!-- Server components -->
> + <dependency>
> + <groupId>org.apache.logging.log4j</groupId>
> + <artifactId>log4j-server</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> <!-- java.util.logging adapter -->
> <dependency>
> <groupId>org.apache.logging.log4j</groupId>
>
>
>
>
>
> --
>
>
> Mikael Ståldal
> Senior software developer
>
> Magine TV
> mikael.staldal@magine.com <ma...@magine.com>
> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com <http://www.magine.com/>
>
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply email.
>
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Remko Popma <re...@gmail.com>.
I guess this is a matter of preference but we already have a lot of modules.
Having one for all standalone applications makes it easier for our users to
find things.
On Mon, Apr 10, 2017 at 11:24 PM, Mikael Ståldal <mi...@magine.com>
wrote:
> Wouldn't it be better to have one for server and another for the other
> tools?
>
> On Mon, Apr 10, 2017 at 4:23 PM, Remko Popma <re...@gmail.com>
> wrote:
>
>> I thought we were going to name this module log4j-tools instead of
>> log4j-server, so it can host all our standalone apps?
>>
>> On Mon, Apr 10, 2017 at 11:11 PM, <mi...@apache.org> wrote:
>>
>>> Update BOM
>>>
>>>
>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit
>>> /fea17ad6
>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f
>>> ea17ad6
>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f
>>> ea17ad6
>>>
>>> Branch: refs/heads/master
>>> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
>>> Parents: 1051081
>>> Author: Mikael Ståldal <mi...@magine.com>
>>> Authored: Mon Apr 10 16:11:24 2017 +0200
>>> Committer: Mikael Ståldal <mi...@magine.com>
>>> Committed: Mon Apr 10 16:11:24 2017 +0200
>>>
>>> ----------------------------------------------------------------------
>>> log4j-bom/pom.xml | 6 ++++++
>>> 1 file changed, 6 insertions(+)
>>> ----------------------------------------------------------------------
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> ea17ad6/log4j-bom/pom.xml
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
>>> index 920f6a0..382f16e 100644
>>> --- a/log4j-bom/pom.xml
>>> +++ b/log4j-bom/pom.xml
>>> @@ -96,6 +96,12 @@
>>> <artifactId>log4j-iostreams</artifactId>
>>> <version>${project.version}</version>
>>> </dependency>
>>> + <!-- Server components -->
>>> + <dependency>
>>> + <groupId>org.apache.logging.log4j</groupId>
>>> + <artifactId>log4j-server</artifactId>
>>> + <version>${project.version}</version>
>>> + </dependency>
>>> <!-- java.util.logging adapter -->
>>> <dependency>
>>> <groupId>org.apache.logging.log4j</groupId>
>>>
>>>
>>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Mikael Ståldal <mi...@magine.com>.
Wouldn't it be better to have one for server and another for the other
tools?
On Mon, Apr 10, 2017 at 4:23 PM, Remko Popma <re...@gmail.com> wrote:
> I thought we were going to name this module log4j-tools instead of
> log4j-server, so it can host all our standalone apps?
>
> On Mon, Apr 10, 2017 at 11:11 PM, <mi...@apache.org> wrote:
>
>> Update BOM
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit
>> /fea17ad6
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6
>>
>> Branch: refs/heads/master
>> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
>> Parents: 1051081
>> Author: Mikael Ståldal <mi...@magine.com>
>> Authored: Mon Apr 10 16:11:24 2017 +0200
>> Committer: Mikael Ståldal <mi...@magine.com>
>> Committed: Mon Apr 10 16:11:24 2017 +0200
>>
>> ----------------------------------------------------------------------
>> log4j-bom/pom.xml | 6 ++++++
>> 1 file changed, 6 insertions(+)
>> ----------------------------------------------------------------------
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>> ea17ad6/log4j-bom/pom.xml
>> ----------------------------------------------------------------------
>> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
>> index 920f6a0..382f16e 100644
>> --- a/log4j-bom/pom.xml
>> +++ b/log4j-bom/pom.xml
>> @@ -96,6 +96,12 @@
>> <artifactId>log4j-iostreams</artifactId>
>> <version>${project.version}</version>
>> </dependency>
>> + <!-- Server components -->
>> + <dependency>
>> + <groupId>org.apache.logging.log4j</groupId>
>> + <artifactId>log4j-server</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> <!-- java.util.logging adapter -->
>> <dependency>
>> <groupId>org.apache.logging.log4j</groupId>
>>
>>
>
--
[image: MagineTV]
*Mikael Ståldal*
Senior software developer
*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.
Re: [14/14] logging-log4j2 git commit: Update BOM
Posted by Remko Popma <re...@gmail.com>.
I thought we were going to name this module log4j-tools instead of
log4j-server, so it can host all our standalone apps?
On Mon, Apr 10, 2017 at 11:11 PM, <mi...@apache.org> wrote:
> Update BOM
>
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/
> commit/fea17ad6
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6
>
> Branch: refs/heads/master
> Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
> Parents: 1051081
> Author: Mikael Ståldal <mi...@magine.com>
> Authored: Mon Apr 10 16:11:24 2017 +0200
> Committer: Mikael Ståldal <mi...@magine.com>
> Committed: Mon Apr 10 16:11:24 2017 +0200
>
> ----------------------------------------------------------------------
> log4j-bom/pom.xml | 6 ++++++
> 1 file changed, 6 insertions(+)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
> fea17ad6/log4j-bom/pom.xml
> ----------------------------------------------------------------------
> diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
> index 920f6a0..382f16e 100644
> --- a/log4j-bom/pom.xml
> +++ b/log4j-bom/pom.xml
> @@ -96,6 +96,12 @@
> <artifactId>log4j-iostreams</artifactId>
> <version>${project.version}</version>
> </dependency>
> + <!-- Server components -->
> + <dependency>
> + <groupId>org.apache.logging.log4j</groupId>
> + <artifactId>log4j-server</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> <!-- java.util.logging adapter -->
> <dependency>
> <groupId>org.apache.logging.log4j</groupId>
>
>
[14/14] logging-log4j2 git commit: Update BOM
Posted by mi...@apache.org.
Update BOM
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fea17ad6
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fea17ad6
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fea17ad6
Branch: refs/heads/master
Commit: fea17ad6bdc47825ec5b58b9df9e031936182d79
Parents: 1051081
Author: Mikael St�ldal <mi...@magine.com>
Authored: Mon Apr 10 16:11:24 2017 +0200
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Mon Apr 10 16:11:24 2017 +0200
----------------------------------------------------------------------
log4j-bom/pom.xml | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fea17ad6/log4j-bom/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-bom/pom.xml b/log4j-bom/pom.xml
index 920f6a0..382f16e 100644
--- a/log4j-bom/pom.xml
+++ b/log4j-bom/pom.xml
@@ -96,6 +96,12 @@
<artifactId>log4j-iostreams</artifactId>
<version>${project.version}</version>
</dependency>
+ <!-- Server components -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- java.util.logging adapter -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
[11/14] logging-log4j2 git commit: Merge branch 'master' into
LOG4J2-1851
Posted by mi...@apache.org.
Merge branch 'master' into LOG4J2-1851
# Conflicts:
# src/changes/changes.xml
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/394c30f5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/394c30f5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/394c30f5
Branch: refs/heads/master
Commit: 394c30f594c9eac570a43313bf44be4bc60cded9
Parents: 6fd6dfc 1475bd9
Author: Mikael St�ldal <mi...@magine.com>
Authored: Mon Apr 10 10:59:27 2017 +0200
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Mon Apr 10 10:59:27 2017 +0200
----------------------------------------------------------------------
BUILDING.md | 2 +-
README.md | 2 +
RELEASE-NOTES.md | 74 ++++++++++---------
log4j-1.2-api/pom.xml | 2 +-
log4j-api-scala_2.10/pom.xml | 2 +-
log4j-api-scala_2.11/pom.xml | 2 +-
log4j-api/pom.xml | 2 +-
.../org/apache/logging/log4j/ThreadContext.java | 5 +-
log4j-bom/pom.xml | 2 +-
log4j-core-its/pom.xml | 2 +-
log4j-core/pom.xml | 2 +-
.../apache/logging/log4j/core/config/Order.java | 2 +-
.../log4j/core/config/OrderComparator.java | 2 +-
.../builder/api/ConfigurationBuilder.java | 15 ++++
.../api/KeyValuePairComponentBuilder.java | 25 +++++++
.../builder/api/PropertyComponentBuilder.java | 25 +++++++
.../impl/DefaultConfigurationBuilder.java | 11 +++
.../DefaultKeyValuePairComponentBuilder.java | 34 +++++++++
.../impl/DefaultPropertyComponentBuilder.java | 32 ++++++++
.../core/util/FilteredObjectInputStream.java | 67 +++++++++++++++++
.../builder/ConfigurationAssemblerTest.java | 6 +-
.../builder/ConfigurationBuilderTest.java | 16 ++++
.../builder/CustomConfigurationFactory.java | 11 +++
log4j-distribution/pom.xml | 2 +-
log4j-distribution/src/assembly/bin.xml | 4 +-
log4j-flume-ng/pom.xml | 2 +-
log4j-iostreams/pom.xml | 2 +-
log4j-jcl/pom.xml | 2 +-
log4j-jmx-gui/pom.xml | 2 +-
log4j-jul/pom.xml | 2 +-
log4j-liquibase/pom.xml | 2 +-
log4j-nosql/pom.xml | 2 +-
log4j-osgi/pom.xml | 2 +-
log4j-perf/pom.xml | 2 +-
log4j-samples/configuration/pom.xml | 2 +-
log4j-samples/flume-common/pom.xml | 2 +-
log4j-samples/flume-embedded/pom.xml | 2 +-
log4j-samples/flume-remote/pom.xml | 2 +-
log4j-samples/loggerProperties/pom.xml | 2 +-
log4j-samples/pom.xml | 2 +-
log4j-samples/scala-api/pom.xml | 2 +-
.../log4j/server/AbstractSocketServer.java | 13 ++++
.../server/ObjectInputStreamLogEventBridge.java | 23 +++++-
.../logging/log4j/server/TcpSocketServer.java | 25 ++++++-
.../logging/log4j/server/UdpSocketServer.java | 18 ++++-
log4j-slf4j-impl/pom.xml | 2 +-
log4j-taglib/pom.xml | 2 +-
log4j-to-slf4j/pom.xml | 2 +-
log4j-web/pom.xml | 2 +-
pom.xml | 31 +++++---
src/changes/changes.xml | 26 ++++++-
src/site/markdown/maven-artifacts.md.vm | 2 +-
src/site/resources/images/logo.png | Bin 40517 -> 40494 bytes
.../logo/logo-electric-blue-2-2.8.2.png | Bin 0 -> 40494 bytes
.../logo/logo-electric-blue-2-2.8.2.xcf | Bin 0 -> 67168 bytes
.../resources/logo/logo-electric-blue-2.xcf | Bin 0 -> 66097 bytes
56 files changed, 437 insertions(+), 90 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/394c30f5/log4j-server/src/main/java/org/apache/logging/log4j/server/AbstractSocketServer.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/AbstractSocketServer.java
index a8f1140,0000000..aff7eb1
mode 100644,000000..100644
--- a/log4j-server/src/main/java/org/apache/logging/log4j/server/AbstractSocketServer.java
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/AbstractSocketServer.java
@@@ -1,209 -1,0 +1,222 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.server;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URL;
++import java.util.Collections;
++import java.util.List;
+import java.util.Objects;
+
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.validators.PositiveInteger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LogEventListener;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.ConfigurationSource;
+import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
+import org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory;
+import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
+import org.apache.logging.log4j.core.util.InetAddressConverter;
+import org.apache.logging.log4j.core.util.Log4jThread;
+import org.apache.logging.log4j.util.Strings;
+
+/**
+ * Abstract socket server for TCP and UDP implementations.
+ *
+ * @param <T>
+ * The kind of input stream read
+ *
+ * TODO Make a LifeCycle
+ */
+public abstract class AbstractSocketServer<T extends InputStream> extends LogEventListener implements Runnable {
+
+ protected static class CommandLineArguments extends BasicCommandLineArguments {
+
+ @Parameter(names = { "--config", "-c" }, description = "Log4j configuration file location (path or URL).")
+ private String configLocation;
+
+ @Parameter(names = { "--interactive",
+ "-i" }, description = "Accepts commands on standard input (\"exit\" is the only command).")
+ private boolean interactive;
+
+ @Parameter(names = { "--port",
+ "-p" }, validateWith = PositiveInteger.class, description = "Server socket port.")
+ private int port;
+
+ @Parameter(names = { "--localbindaddress",
+ "-a" }, converter = InetAddressConverter.class, description = "Server socket local bind address.")
+ private InetAddress localBindAddress;
+
++ @Parameter(names = {"--classes", "-C"}, description = "Additional classes to allow deserialization")
++ private List<String> allowedClasses;
++
+ String getConfigLocation() {
+ return configLocation;
+ }
+
+ int getPort() {
+ return port;
+ }
+
+ protected boolean isInteractive() {
+ return interactive;
+ }
+
+ void setConfigLocation(final String configLocation) {
+ this.configLocation = configLocation;
+ }
+
+ void setInteractive(final boolean interactive) {
+ this.interactive = interactive;
+ }
+
+ void setPort(final int port) {
+ this.port = port;
+ }
+
+ InetAddress getLocalBindAddress() {
+ return localBindAddress;
+ }
+
+ void setLocalBindAddress(final InetAddress localBindAddress) {
+ this.localBindAddress = localBindAddress;
+ }
++
++ List<String> getAllowedClasses() {
++ return allowedClasses == null ? Collections.<String>emptyList() : allowedClasses;
++ }
++
++ void setAllowedClasses(final List<String> allowedClasses) {
++ this.allowedClasses = allowedClasses;
++ }
+ }
+
+ /**
+ * Factory that creates a Configuration for the server.
+ */
+ protected static class ServerConfigurationFactory extends XmlConfigurationFactory {
+
+ private final String path;
+
+ public ServerConfigurationFactory(final String path) {
+ this.path = path;
+ }
+
+ @Override
+ public Configuration getConfiguration(final LoggerContext loggerContext, final String name,
+ final URI configLocation) {
+ if (Strings.isNotEmpty(path)) {
+ File file = null;
+ ConfigurationSource source = null;
+ try {
+ file = new File(path);
+ final FileInputStream is = new FileInputStream(file);
+ source = new ConfigurationSource(is, file);
+ } catch (final FileNotFoundException ignored) {
+ // Ignore this error
+ }
+ if (source == null) {
+ try {
+ final URL url = new URL(path);
+ source = new ConfigurationSource(url.openStream(), url);
+ } catch (final IOException ignored) {
+ // Ignore this error
+ }
+ }
+
+ try {
+ if (source != null) {
+ return new XmlConfiguration(loggerContext, source);
+ }
+ } catch (final Exception ignored) {
+ // Ignore this error.
+ }
+ System.err.println("Unable to process configuration at " + path + ", using default.");
+ }
+ return super.getConfiguration(loggerContext, name, configLocation);
+ }
+ }
+
+ protected static final int MAX_PORT = 65534;
+
+ private volatile boolean active = true;
+
+ protected final LogEventBridge<T> logEventInput;
+
+ protected final Logger logger;
+
+ /**
+ * Creates a new socket server.
+ *
+ * @param port
+ * listen to this port
+ * @param logEventInput
+ * Use this input to read log events.
+ */
+ public AbstractSocketServer(final int port, final LogEventBridge<T> logEventInput) {
+ this.logger = LogManager.getLogger(this.getClass().getName() + '.' + port);
+ this.logEventInput = Objects.requireNonNull(logEventInput, "LogEventInput");
+ }
+
+ protected boolean isActive() {
+ return this.active;
+ }
+
+ protected void setActive(final boolean isActive) {
+ this.active = isActive;
+ }
+
+ /**
+ * Start this server in a new thread.
+ *
+ * @return the new thread that running this server.
+ */
+ public Thread startNewThread() {
+ final Thread thread = new Log4jThread(this);
+ thread.start();
+ return thread;
+ }
+
+ public abstract void shutdown() throws Exception;
+
+ public void awaitTermination(final Thread serverThread) throws Exception {
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
+ while (true) {
+ final String line = reader.readLine();
+ if (line == null
+ || line.equalsIgnoreCase("quit")
+ || line.equalsIgnoreCase("stop")
+ || line.equalsIgnoreCase("exit")) {
+ this.shutdown();
+ serverThread.join();
+ break;
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/394c30f5/log4j-server/src/main/java/org/apache/logging/log4j/server/ObjectInputStreamLogEventBridge.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/ObjectInputStreamLogEventBridge.java
index 9f22b22,0000000..ddd2e26
mode 100644,000000..100644
--- a/log4j-server/src/main/java/org/apache/logging/log4j/server/ObjectInputStreamLogEventBridge.java
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/ObjectInputStreamLogEventBridge.java
@@@ -1,45 -1,0 +1,64 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
++import java.util.Collections;
++import java.util.List;
+
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LogEventListener;
++import org.apache.logging.log4j.core.util.FilteredObjectInputStream;
+
+/**
+ * Reads and logs serialized {@link LogEvent} objects from an {@link ObjectInputStream}.
+ */
+public class ObjectInputStreamLogEventBridge extends AbstractLogEventBridge<ObjectInputStream> {
+
++ private final List<String> allowedClasses;
++
++ public ObjectInputStreamLogEventBridge() {
++ this(Collections.<String>emptyList());
++ }
++
++ /**
++ * Constructs an ObjectInputStreamLogEventBridge with additional allowed classes to deserialize.
++ *
++ * @param allowedClasses class names to also allow for deserialization
++ * @since 2.8.2
++ */
++ public ObjectInputStreamLogEventBridge(final List<String> allowedClasses) {
++ this.allowedClasses = allowedClasses;
++ }
++
+ @Override
+ public void logEvents(final ObjectInputStream inputStream, final LogEventListener logEventListener)
- throws IOException {
++ throws IOException {
+ try {
+ logEventListener.log((LogEvent) inputStream.readObject());
+ } catch (final ClassNotFoundException e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public ObjectInputStream wrapStream(final InputStream inputStream) throws IOException {
- return new ObjectInputStream(inputStream);
++ return new FilteredObjectInputStream(inputStream, allowedClasses);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/394c30f5/log4j-server/src/main/java/org/apache/logging/log4j/server/TcpSocketServer.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/TcpSocketServer.java
index 7856969,0000000..9a5521c
mode 100644,000000..100644
--- a/log4j-server/src/main/java/org/apache/logging/log4j/server/TcpSocketServer.java
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/TcpSocketServer.java
@@@ -1,314 -1,0 +1,333 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.server;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.OptionalDataException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
++import java.util.Collections;
++import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.validators.PositiveInteger;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
+import org.apache.logging.log4j.core.util.Closer;
+import org.apache.logging.log4j.core.util.Log4jThread;
+import org.apache.logging.log4j.message.EntryMessage;
+
+/**
+ * Listens for Log4j events on a TCP server socket and passes them on to Log4j.
+ *
+ * @param <T>
+ * The kind of input stream read
+ * @see #main(String[])
+ */
+public class TcpSocketServer<T extends InputStream> extends AbstractSocketServer<T> {
+
+ protected static class CommandLineArguments extends AbstractSocketServer.CommandLineArguments {
+
+ @Parameter(names = { "--backlog",
+ "-b" }, validateWith = PositiveInteger.class, description = "Server socket backlog.")
+ // Same default as ServerSocket
+ private int backlog = 50;
+
+ int getBacklog() {
+ return backlog;
+ }
+
+ void setBacklog(final int backlog) {
+ this.backlog = backlog;
+ }
+
+ }
+
+ /**
+ * Thread that processes the events.
+ */
+ private class SocketHandler extends Log4jThread {
+
+ private final T inputStream;
+
+ private volatile boolean shutdown = false;
+
+ public SocketHandler(final Socket socket) throws IOException {
+ this.inputStream = logEventInput.wrapStream(socket.getInputStream());
+ }
+
+ @Override
+ public void run() {
+ final EntryMessage entry = logger.traceEntry();
+ boolean closed = false;
+ try {
+ try {
+ while (!shutdown) {
+ logEventInput.logEvents(inputStream, TcpSocketServer.this);
+ }
+ } catch (final EOFException e) {
+ closed = true;
+ } catch (final OptionalDataException e) {
+ logger.error("OptionalDataException eof=" + e.eof + " length=" + e.length, e);
+ } catch (final IOException e) {
+ logger.error("IOException encountered while reading from socket", e);
+ }
+ if (!closed) {
+ Closer.closeSilently(inputStream);
+ }
+ } finally {
+ handlers.remove(Long.valueOf(getId()));
+ }
+ logger.traceExit(entry);
+ }
+
+ public void shutdown() {
+ this.shutdown = true;
+ interrupt();
+ }
+ }
+
+ /**
+ * Creates a socket server that reads JSON log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static TcpSocketServer<InputStream> createJsonSocketServer(final int port) throws IOException {
+ LOGGER.entry("createJsonSocketServer", port);
+ final TcpSocketServer<InputStream> socketServer = new TcpSocketServer<>(port, new JsonInputStreamLogEventBridge());
+ return LOGGER.exit(socketServer);
+ }
+
+ /**
+ * Creates a socket server that reads serialized log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static TcpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port) throws IOException {
+ LOGGER.entry(port);
+ final TcpSocketServer<ObjectInputStream> socketServer = new TcpSocketServer<>(port, new ObjectInputStreamLogEventBridge());
+ return LOGGER.exit(socketServer);
+ }
+
+ /**
+ * Creates a socket server that reads serialized log events.
+ *
+ * @param port the port to listen
+ * @param localBindAddress The server socket's local bin address
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ * @since 2.7
+ */
+ public static TcpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port, final int backlog,
+ final InetAddress localBindAddress) throws IOException {
++ return createSerializedSocketServer(port, backlog, localBindAddress, Collections.<String>emptyList());
++ }
++
++ /**
++ * Creates a socket server that reads serialized log events.
++ *
++ * @param port the port to listen
++ * @param localBindAddress The server socket's local bin address
++ * @param allowedClasses additional class names to allow for deserialization
++ * @return a new a socket server
++ * @throws IOException
++ * if an I/O error occurs when opening the socket.
++ * @since 2.8.2
++ */
++ public static TcpSocketServer<ObjectInputStream> createSerializedSocketServer(
++ final int port, final int backlog, final InetAddress localBindAddress, final List<String> allowedClasses
++ ) throws IOException {
+ LOGGER.entry(port);
+ final TcpSocketServer<ObjectInputStream> socketServer = new TcpSocketServer<>(port, backlog, localBindAddress,
- new ObjectInputStreamLogEventBridge());
++ new ObjectInputStreamLogEventBridge(allowedClasses));
+ return LOGGER.exit(socketServer);
+ }
+
+ /**
+ * Creates a socket server that reads XML log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static TcpSocketServer<InputStream> createXmlSocketServer(final int port) throws IOException {
+ LOGGER.entry(port);
+ final TcpSocketServer<InputStream> socketServer = new TcpSocketServer<>(port, new XmlInputStreamLogEventBridge());
+ return LOGGER.exit(socketServer);
+ }
+
+ /**
+ * Main startup for the server. Run with "--help" for to print command line help on the console.
+ *
+ * @param args
+ * The command line arguments.
+ * @throws Exception
+ * if an error occurs.
+ */
+ public static void main(final String[] args) throws Exception {
+ final CommandLineArguments cla = BasicCommandLineArguments.parseCommandLine(args, TcpSocketServer.class, new CommandLineArguments());
+ if (cla.isHelp()) {
+ return;
+ }
+ if (cla.getConfigLocation() != null) {
+ ConfigurationFactory.setConfigurationFactory(new ServerConfigurationFactory(cla.getConfigLocation()));
+ }
- final TcpSocketServer<ObjectInputStream> socketServer = TcpSocketServer
- .createSerializedSocketServer(cla.getPort(), cla.getBacklog(), cla.getLocalBindAddress());
++ final TcpSocketServer<ObjectInputStream> socketServer = TcpSocketServer.createSerializedSocketServer(
++ cla.getPort(), cla.getBacklog(), cla.getLocalBindAddress(), cla.getAllowedClasses());
+ final Thread serverThread = socketServer.startNewThread();
+ if (cla.isInteractive()) {
+ socketServer.awaitTermination(serverThread);
+ }
+ }
+
+ private final ConcurrentMap<Long, SocketHandler> handlers = new ConcurrentHashMap<>();
+
+ private final ServerSocket serverSocket;
+
+ /**
+ * Constructor.
+ *
+ * @param port
+ * The server socket port.
+ * @param backlog
+ * The server socket backlog.
+ * @param localBindAddress TODO
+ * @param logEventInput
+ * the log even input
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ * @since 2.7
+ */
+ @SuppressWarnings("resource")
+ public TcpSocketServer(final int port, final int backlog, final InetAddress localBindAddress, final LogEventBridge<T> logEventInput) throws IOException {
+ this(port, logEventInput, new ServerSocket(port, backlog, localBindAddress));
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param port
+ * to listen.
+ * @param logEventInput
+ * the log even input
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public TcpSocketServer(final int port, final LogEventBridge<T> logEventInput) throws IOException {
+ this(port, logEventInput, extracted(port));
+ }
+
+ private static ServerSocket extracted(final int port) throws IOException {
+ return new ServerSocket(port);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param port
+ * to listen.
+ * @param logEventInput
+ * the log even input
+ * @param serverSocket
+ * the socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public TcpSocketServer(final int port, final LogEventBridge<T> logEventInput, final ServerSocket serverSocket)
+ throws IOException {
+ super(port, logEventInput);
+ this.serverSocket = serverSocket;
+ }
+
+ /**
+ * Accept incoming events and processes them.
+ */
+ @Override
+ public void run() {
+ final EntryMessage entry = logger.traceEntry();
+ while (isActive()) {
+ if (serverSocket.isClosed()) {
+ return;
+ }
+ try {
+ // Accept incoming connections.
+ logger.debug("Listening for a connection {}...", serverSocket);
+ final Socket clientSocket = serverSocket.accept();
+ logger.debug("Acepted connection on {}...", serverSocket);
+ logger.debug("Socket accepted: {}", clientSocket);
+ clientSocket.setSoLinger(true, 0);
+
+ // accept() will block until a client connects to the server.
+ // If execution reaches this point, then it means that a client
+ // socket has been accepted.
+
+ final SocketHandler handler = new SocketHandler(clientSocket);
+ handlers.put(Long.valueOf(handler.getId()), handler);
+ handler.start();
+ } catch (final IOException e) {
+ if (serverSocket.isClosed()) {
+ // OK we're done.
+ logger.traceExit(entry);
+ return;
+ }
+ logger.error("Exception encountered on accept. Ignoring. Stack trace :", e);
+ }
+ }
+ for (final Map.Entry<Long, SocketHandler> handlerEntry : handlers.entrySet()) {
+ final SocketHandler handler = handlerEntry.getValue();
+ handler.shutdown();
+ try {
+ handler.join();
+ } catch (final InterruptedException ignored) {
+ // Ignore the exception
+ }
+ }
+ logger.traceExit(entry);
+ }
+
+ /**
+ * Shutdown the server.
+ *
+ * @throws IOException if the server socket could not be closed
+ */
+ @Override
+ public void shutdown() throws IOException {
+ final EntryMessage entry = logger.traceEntry();
+ setActive(false);
+ Thread.currentThread().interrupt();
+ serverSocket.close();
+ logger.traceExit(entry);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/394c30f5/log4j-server/src/main/java/org/apache/logging/log4j/server/UdpSocketServer.java
----------------------------------------------------------------------
diff --cc log4j-server/src/main/java/org/apache/logging/log4j/server/UdpSocketServer.java
index a2bac17,0000000..12a8450
mode 100644,000000..100644
--- a/log4j-server/src/main/java/org/apache/logging/log4j/server/UdpSocketServer.java
+++ b/log4j-server/src/main/java/org/apache/logging/log4j/server/UdpSocketServer.java
@@@ -1,169 -1,0 +1,185 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.server;
+
+import java.io.ByteArrayInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.OptionalDataException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
++import java.util.List;
+
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.util.BasicCommandLineArguments;
+
+/**
+ * Listens for Log4j events on a datagram socket and passes them on to Log4j.
+ *
+ * @param <T>
+ * The kind of input stream read
+ * @see #main(String[])
+ */
+public class UdpSocketServer<T extends InputStream> extends AbstractSocketServer<T> {
+
+ /**
+ * Creates a socket server that reads JSON log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static UdpSocketServer<InputStream> createJsonSocketServer(final int port) throws IOException {
+ return new UdpSocketServer<>(port, new JsonInputStreamLogEventBridge());
+ }
+
+ /**
+ * Creates a socket server that reads serialized log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static UdpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port) throws IOException {
+ return new UdpSocketServer<>(port, new ObjectInputStreamLogEventBridge());
+ }
+
+ /**
++ * Creates a socket server that reads serialized log events.
++ *
++ * @param port the port to listen
++ * @param allowedClasses additional classes to allow for deserialization
++ * @return a new a socket server
++ * @throws IOException if an I/O error occurs when opening the socket.
++ * @since 2.8.2
++ */
++ public static UdpSocketServer<ObjectInputStream> createSerializedSocketServer(final int port,
++ final List<String> allowedClasses)
++ throws IOException {
++ return new UdpSocketServer<>(port, new ObjectInputStreamLogEventBridge(allowedClasses));
++ }
++
++ /**
+ * Creates a socket server that reads XML log events.
+ *
+ * @param port
+ * the port to listen
+ * @return a new a socket server
+ * @throws IOException
+ * if an I/O error occurs when opening the socket.
+ */
+ public static UdpSocketServer<InputStream> createXmlSocketServer(final int port) throws IOException {
+ return new UdpSocketServer<>(port, new XmlInputStreamLogEventBridge());
+ }
+
+ /**
+ * Main startup for the server. Run with "--help" for to print command line help on the console.
+ *
+ * @param args
+ * The command line arguments.
+ * @throws Exception
+ * if an error occurs.
+ */
+ public static void main(final String[] args) throws Exception {
+ final CommandLineArguments cla = BasicCommandLineArguments.parseCommandLine(args, UdpSocketServer.class, new CommandLineArguments());
+ if (cla.isHelp()) {
+ return;
+ }
+ if (cla.getConfigLocation() != null) {
+ ConfigurationFactory.setConfigurationFactory(new ServerConfigurationFactory(cla.getConfigLocation()));
+ }
+ final UdpSocketServer<ObjectInputStream> socketServer = UdpSocketServer
- .createSerializedSocketServer(cla.getPort());
++ .createSerializedSocketServer(cla.getPort(), cla.getAllowedClasses());
+ final Thread serverThread = socketServer.startNewThread();
+ if (cla.isInteractive()) {
+ socketServer.awaitTermination(serverThread);
+ }
+ }
+
+ private final DatagramSocket datagramSocket;
+
+ // max size so we only have to deal with one packet
+ private final int maxBufferSize = 1024 * 65 + 1024;
+
+ /**
+ * Constructor.
+ *
+ * @param port
+ * to listen on.
+ * @param logEventInput
+ * @throws IOException
+ * If an error occurs.
+ */
+ public UdpSocketServer(final int port, final LogEventBridge<T> logEventInput) throws IOException {
+ super(port, logEventInput);
+ this.datagramSocket = new DatagramSocket(port);
+ }
+
+ /**
+ * Accept incoming events and processes them.
+ */
+ @Override
+ public void run() {
+ while (isActive()) {
+ if (datagramSocket.isClosed()) {
+ // OK we're done.
+ return;
+ }
+ try {
+ final byte[] buf = new byte[maxBufferSize];
+ final DatagramPacket packet = new DatagramPacket(buf, buf.length);
+ datagramSocket.receive(packet);
+ final ByteArrayInputStream bais = new ByteArrayInputStream(packet.getData(), packet.getOffset(), packet.getLength());
+ logEventInput.logEvents(logEventInput.wrapStream(bais), this);
+ } catch (final OptionalDataException e) {
+ if (datagramSocket.isClosed()) {
+ // OK we're done.
+ return;
+ }
+ logger.error("OptionalDataException eof=" + e.eof + " length=" + e.length, e);
+ } catch (final EOFException e) {
+ if (datagramSocket.isClosed()) {
+ // OK we're done.
+ return;
+ }
+ logger.info("EOF encountered");
+ } catch (final IOException e) {
+ if (datagramSocket.isClosed()) {
+ // OK we're done.
+ return;
+ }
+ logger.error("Exception encountered on accept. Ignoring. Stack Trace :", e);
+ }
+ }
+ }
+
+ /**
+ * Shutdown the server.
+ */
+ @Override
+ public void shutdown() {
+ this.setActive(false);
+ Thread.currentThread().interrupt();
+ datagramSocket.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/394c30f5/pom.xml
----------------------------------------------------------------------
[12/14] logging-log4j2 git commit: Update changelog
Posted by mi...@apache.org.
Update changelog
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ea14d1ce
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ea14d1ce
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ea14d1ce
Branch: refs/heads/master
Commit: ea14d1ce1e741782bc649a1ea1f3517317a11605
Parents: 394c30f
Author: Mikael St�ldal <mi...@magine.com>
Authored: Mon Apr 10 10:59:49 2017 +0200
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Mon Apr 10 10:59:49 2017 +0200
----------------------------------------------------------------------
src/changes/changes.xml | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ea14d1ce/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 1c6a7f8..ab3a5b0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -31,6 +31,9 @@
- "remove" - Removed
-->
<release version="2.9.0" date="2017-MM-DD" description="GA Release 2.9.0">
+ <action issue="LOG4J2-1851" dev="mikes" type="update">
+ Move server components from log4j-core to new log4-server module.
+ </action>
<action issue="LOG4J2-1860" dev="mikes" type="add">
Shortcut to add Property and KeyValuePair component in ConfigurationBuilder.
</action>
[08/14] logging-log4j2 git commit: Remove mentioning of SocketServer
from appender manual
Posted by mi...@apache.org.
Remove mentioning of SocketServer from appender manual
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/179ad05e
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/179ad05e
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/179ad05e
Branch: refs/heads/master
Commit: 179ad05e956c64f231b0f218e5db4f0a2299e2ac
Parents: f822bd8
Author: Mikael St�ldal <mi...@magine.com>
Authored: Fri Mar 17 16:13:36 2017 +0100
Committer: Mikael St�ldal <mi...@magine.com>
Committed: Fri Mar 17 16:13:36 2017 +0100
----------------------------------------------------------------------
src/site/xdoc/manual/appenders.xml | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/179ad05e/src/site/xdoc/manual/appenders.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/appenders.xml b/src/site/xdoc/manual/appenders.xml
index bd60dfc..c306b39 100644
--- a/src/site/xdoc/manual/appenders.xml
+++ b/src/site/xdoc/manual/appenders.xml
@@ -3999,9 +3999,7 @@ public class JpaLogEntity extends AbstractLogEventWrapperEntity {
<p>
The <code>SocketAppender</code> is an OutputStreamAppender that writes its output to a remote destination
specified by a host and port. The data can be sent over either TCP or UDP and can be sent in any format.
- The default format is to send a Serialized LogEvent. Log4j 2 contains a SocketServer which is capable
- of receiving serialized LogEvents and routing them through the logging system on the server. You can optionally
- secure communication with SSL.
+ The default format is to send a Serialized LogEvent. You can optionally secure communication with SSL.
</p>
<table>
<caption align="top"><code>SocketAppender</code> Parameters</caption>