[jira] [Closed] (LOG4J2-2402) NTEventLogAppender has security issues

2018-08-08 Thread Ralph Goers (JIRA)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-2402?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ralph Goers closed LOG4J2-2402.
---
Resolution: Invalid

I am closing this as invalid for all the reasons already stated. Log4j 1.x is 
EOL for a long time now and no bug fixes or security patches will ever be 
produced by this project.

Furthermore, as the issue type implies, Jira issues of type LOG4J2 are only for 
Log4j 2 or one of its related components. 

> NTEventLogAppender has security issues
> --
>
> Key: LOG4J2-2402
> URL: https://issues.apache.org/jira/browse/LOG4J2-2402
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Appenders
>Affects Versions: 2.4.1
> Environment: Windows 2012 R2
> Windows 2010
>Reporter: Rolando Sanchez Villalobos
>Priority: Major
>
> The NTEventLogAppender.amd64.dll was reviewed by security testers and showed 
> the following issues
> - Executable not signed or code signature missing. 
>  - No Address Space Layout Randomization (ASLR).
>  - Software Enforce Data Execution Prevention (DEP) Enabled.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2399) Reusable Messages do not respect log4j.format.msg.async

2018-08-08 Thread Carter Kozak (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16574054#comment-16574054
 ] 

Carter Kozak commented on LOG4J2-2399:
--

Absolutely, I'll put together some concrete benchmarks and post the results 
here. I'm not planning on merging anything for this ticket until several of us 
are in agreement that it's worth the complexity.

> Reusable Messages do not respect log4j.format.msg.async
> ---
>
> Key: LOG4J2-2399
> URL: https://issues.apache.org/jira/browse/LOG4J2-2399
> Project: Log4j 2
>  Issue Type: Task
>  Components: Core
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
>
> Setting "log4j.format.msg.async" applies only to messages that do not 
> implement ReusableMessage.
> On applications using asynchronous logging with message formatting in the 
> background there is a measurable performance cost to using 
> ReusableParameterizedMessages instead of ParameterizedMessages due to 
> formatting on the application thread 
> (MutableLogEvent/RingBufferLogEvent.setMessage).
> I have a custom layout which does not log formatted messages in most cases, 
> but the format string and parameter values separately in order to analyze 
> values logged over time bucketed by logger name and format string. In this 
> case the formatting is unnecessary work. It is possible to implement a custom 
> message factory which doesn't format message data, however that would break 
> the ability to add a standard pattern layout in addition to the custom 
> formatter.
> h2. Proposed Design
> Our reusable events (MutableLogEvent and RingBufferLogEvent) currently 
> capture most of the required information, the format string and parameter 
> array, but are missing a bit of context for how the original message 
> implementation would format that data.
> ReusableMessage implementations may optionally extend 
> "MessageContentFormatterProvider"
> {code:java}
> interface MessageContentFormatterProvider {
>   MessageContentFormatter getMessageContentFormatter();
> }{code}
> Where MessageContentFormatter takes the form:
> {code:java}
> interface MessageContentFormatter {
>   void appendTo(StringBuilder dest, String format, Object[] params, short 
> paramCount);
> }{code}
> Reusable log event implementations will be updated to hold a reference to the 
> content formatter (instead of formatting to the local event buffer) when 
> asynchronous formatting is enabled _and_ the message is an instance of 
> MessageContentFormatterProvider.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2399) Reusable Messages do not respect log4j.format.msg.async

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16574043#comment-16574043
 ] 

ASF GitHub Bot commented on LOG4J2-2399:


Github user remkop commented on the issue:

https://github.com/apache/logging-log4j2/pull/205
  
@bjlaub @cakofony Please see my comment on the [jira ticket](

https://issues.apache.org/jira/browse/LOG4J2-2399?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel=16573738#comment-16573738)
 about the need for a benchmark that demonstrates the expected performance 
gain. 


> Reusable Messages do not respect log4j.format.msg.async
> ---
>
> Key: LOG4J2-2399
> URL: https://issues.apache.org/jira/browse/LOG4J2-2399
> Project: Log4j 2
>  Issue Type: Task
>  Components: Core
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
>
> Setting "log4j.format.msg.async" applies only to messages that do not 
> implement ReusableMessage.
> On applications using asynchronous logging with message formatting in the 
> background there is a measurable performance cost to using 
> ReusableParameterizedMessages instead of ParameterizedMessages due to 
> formatting on the application thread 
> (MutableLogEvent/RingBufferLogEvent.setMessage).
> I have a custom layout which does not log formatted messages in most cases, 
> but the format string and parameter values separately in order to analyze 
> values logged over time bucketed by logger name and format string. In this 
> case the formatting is unnecessary work. It is possible to implement a custom 
> message factory which doesn't format message data, however that would break 
> the ability to add a standard pattern layout in addition to the custom 
> formatter.
> h2. Proposed Design
> Our reusable events (MutableLogEvent and RingBufferLogEvent) currently 
> capture most of the required information, the format string and parameter 
> array, but are missing a bit of context for how the original message 
> implementation would format that data.
> ReusableMessage implementations may optionally extend 
> "MessageContentFormatterProvider"
> {code:java}
> interface MessageContentFormatterProvider {
>   MessageContentFormatter getMessageContentFormatter();
> }{code}
> Where MessageContentFormatter takes the form:
> {code:java}
> interface MessageContentFormatter {
>   void appendTo(StringBuilder dest, String format, Object[] params, short 
> paramCount);
> }{code}
> Reusable log event implementations will be updated to hold a reference to the 
> content formatter (instead of formatting to the local event buffer) when 
> asynchronous formatting is enabled _and_ the message is an instance of 
> MessageContentFormatterProvider.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] logging-log4j2 issue #205: [LOG4J2-2399] support for async formatting on reu...

2018-08-08 Thread remkop
Github user remkop commented on the issue:

https://github.com/apache/logging-log4j2/pull/205
  
@bjlaub @cakofony Please see my comment on the [jira ticket](

https://issues.apache.org/jira/browse/LOG4J2-2399?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel=16573738#comment-16573738)
 about the need for a benchmark that demonstrates the expected performance 
gain. 


---


[jira] [Commented] (LOG4J2-2399) Reusable Messages do not respect log4j.format.msg.async

2018-08-08 Thread Remko Popma (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16574035#comment-16574035
 ] 

Remko Popma commented on LOG4J2-2399:
-

Supporting async formatting is likely to make the code significantly more 
complex. 
There needs to be an equally significant performance gain to make it worth it. 

Can you give any indication (ideally with a JMH benchmark) of what the expected 
performance gains are for this change? 

> Reusable Messages do not respect log4j.format.msg.async
> ---
>
> Key: LOG4J2-2399
> URL: https://issues.apache.org/jira/browse/LOG4J2-2399
> Project: Log4j 2
>  Issue Type: Task
>  Components: Core
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
>
> Setting "log4j.format.msg.async" applies only to messages that do not 
> implement ReusableMessage.
> On applications using asynchronous logging with message formatting in the 
> background there is a measurable performance cost to using 
> ReusableParameterizedMessages instead of ParameterizedMessages due to 
> formatting on the application thread 
> (MutableLogEvent/RingBufferLogEvent.setMessage).
> I have a custom layout which does not log formatted messages in most cases, 
> but the format string and parameter values separately in order to analyze 
> values logged over time bucketed by logger name and format string. In this 
> case the formatting is unnecessary work. It is possible to implement a custom 
> message factory which doesn't format message data, however that would break 
> the ability to add a standard pattern layout in addition to the custom 
> formatter.
> h2. Proposed Design
> Our reusable events (MutableLogEvent and RingBufferLogEvent) currently 
> capture most of the required information, the format string and parameter 
> array, but are missing a bit of context for how the original message 
> implementation would format that data.
> ReusableMessage implementations may optionally extend 
> "MessageContentFormatterProvider"
> {code:java}
> interface MessageContentFormatterProvider {
>   MessageContentFormatter getMessageContentFormatter();
> }{code}
> Where MessageContentFormatter takes the form:
> {code:java}
> interface MessageContentFormatter {
>   void appendTo(StringBuilder dest, String format, Object[] params, short 
> paramCount);
> }{code}
> Reusable log event implementations will be updated to hold a reference to the 
> content formatter (instead of formatting to the local event buffer) when 
> asynchronous formatting is enabled _and_ the message is an instance of 
> MessageContentFormatterProvider.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2402) NTEventLogAppender has security issues

2018-08-08 Thread Remko Popma (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16574031#comment-16574031
 ] 

Remko Popma commented on LOG4J2-2402:
-

Also, in future please don’t post potential security issues to public forums 
like this issue tracker. Instead, contact the Apache Security Team 
(http://apache.org/security/ ) who can help coordinate the response. 

This gives the maintainers some time to address the issue and release a patch 
before knowledge of the problem becomes widespread. 

> NTEventLogAppender has security issues
> --
>
> Key: LOG4J2-2402
> URL: https://issues.apache.org/jira/browse/LOG4J2-2402
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Appenders
>Affects Versions: 2.4.1
> Environment: Windows 2012 R2
> Windows 2010
>Reporter: Rolando Sanchez Villalobos
>Priority: Major
>
> The NTEventLogAppender.amd64.dll was reviewed by security testers and showed 
> the following issues
> - Executable not signed or code signature missing. 
>  - No Address Space Layout Randomization (ASLR).
>  - Software Enforce Data Execution Prevention (DEP) Enabled.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2402) NTEventLogAppender has security issues

2018-08-08 Thread Remko Popma (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16574027#comment-16574027
 ] 

Remko Popma commented on LOG4J2-2402:
-

NTEventLogAppender is a Log4j 1.2 appender. (This issue tracker is intended for 
 Log4j 2 issues, but that’s fine.)

Log4j 1.2 has been End of Life since August 2015. I’m not sure what more we can 
do. 

> NTEventLogAppender has security issues
> --
>
> Key: LOG4J2-2402
> URL: https://issues.apache.org/jira/browse/LOG4J2-2402
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Appenders
>Affects Versions: 2.4.1
> Environment: Windows 2012 R2
> Windows 2010
>Reporter: Rolando Sanchez Villalobos
>Priority: Major
>
> The NTEventLogAppender.amd64.dll was reviewed by security testers and showed 
> the following issues
> - Executable not signed or code signature missing. 
>  - No Address Space Layout Randomization (ASLR).
>  - Software Enforce Data Execution Prevention (DEP) Enabled.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] logging-log4j2 pull request #207: [proposal] Add "log4j2.enable.throwable.pr...

2018-08-08 Thread cakofony
GitHub user cakofony opened a pull request:

https://github.com/apache/logging-log4j2/pull/207

[proposal] Add "log4j2.enable.throwable.proxy" to disable ThrowableProxy

This is not expected to be compatible with java serialized
objects or the jackson layout, both of which require a
ThrowableProxy.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/cakofony/logging-log4j2 
ckozak/prop_disable_throwable_proxy

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/logging-log4j2/pull/207.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #207


commit e3dbc67e80a0cef9d83bc2fbc171c8e5be6996e4
Author: Carter Kozak 
Date:   2018-08-08T14:42:20Z

Add "log4j2.enable.throwable.proxy" to disable ThrowableProxy

This is not expected to be compatible with java serialized
objects or the jackson layout, both of which require a
ThrowableProxy.




---


[jira] [Commented] (LOG4J2-2400) Support for log4j2 RedisAppender

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573890#comment-16573890
 ] 

ASF GitHub Bot commented on LOG4J2-2400:


Github user garydgregory commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208736183
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
+
+@SuppressWarnings("resource")
+@Override
+public RedisAppender build() {
+return new RedisAppender(getName(), getLayout(), getFilter(), 
isIgnoreExceptions(), getRedisManager());
+}
+
+public Charset getCharset() {
+if (getLayout() instanceof AbstractStringLayout) {
+return ((AbstractStringLayout) getLayout()).getCharset();
+} else {
+return Charset.defaultCharset();
+}
+}
+
+String[] getKeys() {
+return keys;
+}
+
+String getHost() {
+return host;
+}
+
+boolean getSsl() {
+return ssl;
+}
+
+int getPort() {
+return port;
+}
+
+public B withKeys(final String key) {
+this.keys = new String[]{key};
+return asBuilder();
+}
--- End diff --

I think we should use "set" as the setter prefix instead of "with".


> Support for log4j2 RedisAppender
> 
>
> Key: LOG4J2-2400
> URL: https://issues.apache.org/jira/browse/LOG4J2-2400
> Project: Log4j 2
>  

[GitHub] logging-log4j2 pull request #206: [LOG4J2-2400] Initial implementation of Re...

2018-08-08 Thread garydgregory
Github user garydgregory commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208736183
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
+
+@SuppressWarnings("resource")
+@Override
+public RedisAppender build() {
+return new RedisAppender(getName(), getLayout(), getFilter(), 
isIgnoreExceptions(), getRedisManager());
+}
+
+public Charset getCharset() {
+if (getLayout() instanceof AbstractStringLayout) {
+return ((AbstractStringLayout) getLayout()).getCharset();
+} else {
+return Charset.defaultCharset();
+}
+}
+
+String[] getKeys() {
+return keys;
+}
+
+String getHost() {
+return host;
+}
+
+boolean getSsl() {
+return ssl;
+}
+
+int getPort() {
+return port;
+}
+
+public B withKeys(final String key) {
+this.keys = new String[]{key};
+return asBuilder();
+}
--- End diff --

I think we should use "set" as the setter prefix instead of "with".


---


[GitHub] logging-log4j2 pull request #206: [LOG4J2-2400] Initial implementation of Re...

2018-08-08 Thread garydgregory
Github user garydgregory commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208735895
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
--- End diff --

+1


---


[jira] [Commented] (LOG4J2-2400) Support for log4j2 RedisAppender

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573881#comment-16573881
 ] 

ASF GitHub Bot commented on LOG4J2-2400:


Github user garydgregory commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208735895
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
--- End diff --

+1


> Support for log4j2 RedisAppender
> 
>
> Key: LOG4J2-2400
> URL: https://issues.apache.org/jira/browse/LOG4J2-2400
> Project: Log4j 2
>  Issue Type: New Feature
>  Components: Appenders
>Reporter: Kevin Andrew Meurer
>Priority: Major
>
> Redis functions well as a temporary queue for event data en route to another 
> data store. For example, Redis may be used to improve the fault-tolerance of 
> a logging pipeline by serving as an intermediary as log events move to a 
> separate storage layer (i.e. log4j2 - > Redis < - Logstash -> Elasticsearch).
> As a result, event processing applications may wish to use Redis instead of 
> Kafka as a message broker. We should add support for a RedisAppender to 
> support this use case.
> Relevant dev list thread: 
> [https://lists.apache.org/thread.html/4967cf3cd4db367ba563143ccd1438b7c53830671881eb692642b8d9@%3Cdev.logging.apache.org%3E]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2400) Support for log4j2 RedisAppender

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573871#comment-16573871
 ] 

ASF GitHub Bot commented on LOG4J2-2400:


Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208730159
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisManager.java
 ---
@@ -0,0 +1,86 @@
+package org.apache.logging.log4j.redis.appender;
+
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.AbstractManager;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.JedisPoolConfig;
+import redis.clients.jedis.exceptions.JedisConnectionException;
+
+import java.nio.charset.Charset;
+import java.util.concurrent.TimeUnit;
+
+class RedisManager extends AbstractManager {
+
+private final byte[][] byteKeys;
+private final String host;
+private final int port;
+private final Charset charset;
+private final boolean ssl;
+private JedisPool jedisPool;
+
+RedisManager(LoggerContext loggerContext, String name, String[] keys, 
String host, int port, boolean ssl, Charset charset) {
+super(loggerContext, name);
+this.byteKeys = new byte[keys.length][];
+for (int i = 0; i < keys.length; i++) {
+this.byteKeys[i] = keys[i].getBytes(charset);
+}
+this.charset = charset;
+this.host = host;
+this.port = port;
+this.ssl = ssl;
+}
+
+JedisPool createPool(String host, int port, boolean ssl) {
+JedisPoolConfig poolConfig = new JedisPoolConfig();
+poolConfig.setMaxIdle(5);
+poolConfig.setMinIdle(1);
+poolConfig.setTestOnBorrow(true);
+poolConfig.setTestOnReturn(true);
+poolConfig.setTestWhileIdle(true);
+poolConfig.setNumTestsPerEvictionRun(10);
+poolConfig.setTimeBetweenEvictionRunsMillis(6);
+return new JedisPool(poolConfig, host, port, ssl);
--- End diff --

Can we make all the jedis pool config parameters configurable?


> Support for log4j2 RedisAppender
> 
>
> Key: LOG4J2-2400
> URL: https://issues.apache.org/jira/browse/LOG4J2-2400
> Project: Log4j 2
>  Issue Type: New Feature
>  Components: Appenders
>Reporter: Kevin Andrew Meurer
>Priority: Major
>
> Redis functions well as a temporary queue for event data en route to another 
> data store. For example, Redis may be used to improve the fault-tolerance of 
> a logging pipeline by serving as an intermediary as log events move to a 
> separate storage layer (i.e. log4j2 - > Redis < - Logstash -> Elasticsearch).
> As a result, event processing applications may wish to use Redis instead of 
> Kafka as a message broker. We should add support for a RedisAppender to 
> support this use case.
> Relevant dev list thread: 
> [https://lists.apache.org/thread.html/4967cf3cd4db367ba563143ccd1438b7c53830671881eb692642b8d9@%3Cdev.logging.apache.org%3E]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2400) Support for log4j2 RedisAppender

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573868#comment-16573868
 ] 

ASF GitHub Bot commented on LOG4J2-2400:


Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208727430
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
+
+@SuppressWarnings("resource")
+@Override
+public RedisAppender build() {
+return new RedisAppender(getName(), getLayout(), getFilter(), 
isIgnoreExceptions(), getRedisManager());
+}
+
+public Charset getCharset() {
+if (getLayout() instanceof AbstractStringLayout) {
+return ((AbstractStringLayout) getLayout()).getCharset();
+} else {
+return Charset.defaultCharset();
+}
+}
+
+String[] getKeys() {
+return keys;
+}
+
+String getHost() {
+return host;
+}
+
+boolean getSsl() {
+return ssl;
+}
+
+int getPort() {
+return port;
+}
+
+public B withKeys(final String key) {
+this.keys = new String[]{key};
+return asBuilder();
+}
+
+public B withKeys(final String[] keys) {
+this.keys = keys;
+return asBuilder();
+}
+
+public B withHost(final String host) {
+this.host = host;
+return asBuilder();
+}
+
+public B 

[jira] [Commented] (LOG4J2-2400) Support for log4j2 RedisAppender

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573870#comment-16573870
 ] 

ASF GitHub Bot commented on LOG4J2-2400:


Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208734762
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
+
+@SuppressWarnings("resource")
+@Override
+public RedisAppender build() {
+return new RedisAppender(getName(), getLayout(), getFilter(), 
isIgnoreExceptions(), getRedisManager());
+}
+
+public Charset getCharset() {
+if (getLayout() instanceof AbstractStringLayout) {
+return ((AbstractStringLayout) getLayout()).getCharset();
+} else {
+return Charset.defaultCharset();
+}
+}
+
+String[] getKeys() {
+return keys;
+}
+
+String getHost() {
+return host;
+}
+
+boolean getSsl() {
+return ssl;
+}
+
+int getPort() {
+return port;
+}
+
+public B withKeys(final String key) {
+this.keys = new String[]{key};
+return asBuilder();
+}
+
+public B withKeys(final String[] keys) {
+this.keys = keys;
+return asBuilder();
+}
+
+public B withHost(final String host) {
+this.host = host;
+return asBuilder();
+}
+
+public B 

[jira] [Commented] (LOG4J2-2400) Support for log4j2 RedisAppender

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573873#comment-16573873
 ] 

ASF GitHub Bot commented on LOG4J2-2400:


Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208725886
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
--- End diff --

Can we support `org.apache.logging.log4j.core.net.ssl.SslConfiguration` 
rather than forcing the jvm default truststore?


> Support for log4j2 RedisAppender
> 
>
> Key: LOG4J2-2400
> URL: https://issues.apache.org/jira/browse/LOG4J2-2400
> Project: Log4j 2
>  Issue Type: New Feature
>  Components: Appenders
>Reporter: Kevin Andrew Meurer
>Priority: Major
>
> Redis functions well as a temporary queue for event data en route to another 
> data store. For example, Redis may be used to improve the fault-tolerance of 
> a logging pipeline by serving as an intermediary as log events move to a 
> separate storage layer (i.e. log4j2 - > Redis < - Logstash -> Elasticsearch).
> As a result, event processing applications may wish to use Redis instead of 
> Kafka as a message broker. We should add support for a RedisAppender to 
> support this use case.
> Relevant dev list thread: 
> [https://lists.apache.org/thread.html/4967cf3cd4db367ba563143ccd1438b7c53830671881eb692642b8d9@%3Cdev.logging.apache.org%3E]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2400) Support for log4j2 RedisAppender

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573872#comment-16573872
 ] 

ASF GitHub Bot commented on LOG4J2-2400:


Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208727677
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
+
+@SuppressWarnings("resource")
+@Override
+public RedisAppender build() {
+return new RedisAppender(getName(), getLayout(), getFilter(), 
isIgnoreExceptions(), getRedisManager());
+}
+
+public Charset getCharset() {
+if (getLayout() instanceof AbstractStringLayout) {
+return ((AbstractStringLayout) getLayout()).getCharset();
+} else {
+return Charset.defaultCharset();
+}
+}
+
+String[] getKeys() {
+return keys;
+}
+
+String getHost() {
+return host;
+}
+
+boolean getSsl() {
+return ssl;
+}
+
+int getPort() {
+return port;
+}
+
+public B withKeys(final String key) {
+this.keys = new String[]{key};
+return asBuilder();
+}
+
+public B withKeys(final String[] keys) {
+this.keys = keys;
+return asBuilder();
+}
+
+public B withHost(final String host) {
+this.host = host;
+return asBuilder();
+}
+
+public B 

[jira] [Commented] (LOG4J2-2400) Support for log4j2 RedisAppender

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573869#comment-16573869
 ] 

ASF GitHub Bot commented on LOG4J2-2400:


Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208729348
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
+
+@SuppressWarnings("resource")
+@Override
+public RedisAppender build() {
+return new RedisAppender(getName(), getLayout(), getFilter(), 
isIgnoreExceptions(), getRedisManager());
+}
+
+public Charset getCharset() {
+if (getLayout() instanceof AbstractStringLayout) {
+return ((AbstractStringLayout) getLayout()).getCharset();
+} else {
+return Charset.defaultCharset();
+}
+}
+
+String[] getKeys() {
+return keys;
+}
+
+String getHost() {
+return host;
+}
+
+boolean getSsl() {
+return ssl;
+}
+
+int getPort() {
+return port;
+}
+
+public B withKeys(final String key) {
+this.keys = new String[]{key};
+return asBuilder();
+}
+
+public B withKeys(final String[] keys) {
+this.keys = keys;
+return asBuilder();
+}
+
+public B withHost(final String host) {
+this.host = host;
+return asBuilder();
+}
+
+public B 

[GitHub] logging-log4j2 pull request #206: [LOG4J2-2400] Initial implementation of Re...

2018-08-08 Thread cakofony
Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208727430
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
+
+@SuppressWarnings("resource")
+@Override
+public RedisAppender build() {
+return new RedisAppender(getName(), getLayout(), getFilter(), 
isIgnoreExceptions(), getRedisManager());
+}
+
+public Charset getCharset() {
+if (getLayout() instanceof AbstractStringLayout) {
+return ((AbstractStringLayout) getLayout()).getCharset();
+} else {
+return Charset.defaultCharset();
+}
+}
+
+String[] getKeys() {
+return keys;
+}
+
+String getHost() {
+return host;
+}
+
+boolean getSsl() {
+return ssl;
+}
+
+int getPort() {
+return port;
+}
+
+public B withKeys(final String key) {
+this.keys = new String[]{key};
+return asBuilder();
+}
+
+public B withKeys(final String[] keys) {
+this.keys = keys;
+return asBuilder();
+}
+
+public B withHost(final String host) {
+this.host = host;
+return asBuilder();
+}
+
+public B withPort(final int port) {
+this.port = port;
+return asBuilder();
+}
+
+public B withSsl(final boolean ssl) {
+this.ssl = ssl;
+return asBuilder();
   

[GitHub] logging-log4j2 pull request #206: [LOG4J2-2400] Initial implementation of Re...

2018-08-08 Thread cakofony
Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208729348
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
+
+@SuppressWarnings("resource")
+@Override
+public RedisAppender build() {
+return new RedisAppender(getName(), getLayout(), getFilter(), 
isIgnoreExceptions(), getRedisManager());
+}
+
+public Charset getCharset() {
+if (getLayout() instanceof AbstractStringLayout) {
+return ((AbstractStringLayout) getLayout()).getCharset();
+} else {
+return Charset.defaultCharset();
+}
+}
+
+String[] getKeys() {
+return keys;
+}
+
+String getHost() {
+return host;
+}
+
+boolean getSsl() {
+return ssl;
+}
+
+int getPort() {
+return port;
+}
+
+public B withKeys(final String key) {
+this.keys = new String[]{key};
+return asBuilder();
+}
+
+public B withKeys(final String[] keys) {
+this.keys = keys;
+return asBuilder();
+}
+
+public B withHost(final String host) {
+this.host = host;
+return asBuilder();
+}
+
+public B withPort(final int port) {
+this.port = port;
+return asBuilder();
+}
+
+public B withSsl(final boolean ssl) {
+this.ssl = ssl;
+return asBuilder();
   

[GitHub] logging-log4j2 pull request #206: [LOG4J2-2400] Initial implementation of Re...

2018-08-08 Thread cakofony
Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208725886
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
--- End diff --

Can we support `org.apache.logging.log4j.core.net.ssl.SslConfiguration` 
rather than forcing the jvm default truststore?


---


[GitHub] logging-log4j2 pull request #206: [LOG4J2-2400] Initial implementation of Re...

2018-08-08 Thread cakofony
Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208727677
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
+
+@SuppressWarnings("resource")
+@Override
+public RedisAppender build() {
+return new RedisAppender(getName(), getLayout(), getFilter(), 
isIgnoreExceptions(), getRedisManager());
+}
+
+public Charset getCharset() {
+if (getLayout() instanceof AbstractStringLayout) {
+return ((AbstractStringLayout) getLayout()).getCharset();
+} else {
+return Charset.defaultCharset();
+}
+}
+
+String[] getKeys() {
+return keys;
+}
+
+String getHost() {
+return host;
+}
+
+boolean getSsl() {
+return ssl;
+}
+
+int getPort() {
+return port;
+}
+
+public B withKeys(final String key) {
+this.keys = new String[]{key};
+return asBuilder();
+}
+
+public B withKeys(final String[] keys) {
+this.keys = keys;
+return asBuilder();
+}
+
+public B withHost(final String host) {
+this.host = host;
+return asBuilder();
+}
+
+public B withPort(final int port) {
+this.port = port;
+return asBuilder();
+}
+
+public B withSsl(final boolean ssl) {
+this.ssl = ssl;
+return asBuilder();
   

[GitHub] logging-log4j2 pull request #206: [LOG4J2-2400] Initial implementation of Re...

2018-08-08 Thread cakofony
Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208734762
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisAppender.java
 ---
@@ -0,0 +1,202 @@
+/*
+ * 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.redis.appender;
+
+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.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.layout.AbstractStringLayout;
+
+import java.io.Serializable;
+import java.nio.charset.Charset;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sends log events to a Redis Queue. All logs are appended Redis lists 
via the RPUSH command.
+ */
+@Plugin(name = "Redis", category = Node.CATEGORY, elementType = 
Appender.ELEMENT_TYPE, printObject = true)
+public final class RedisAppender extends AbstractAppender {
+
+private RedisAppender(final String name, final Layout layout, final Filter filter,
+  final boolean ignoreExceptions, final 
RedisManager manager) {
+super(name, filter, layout, ignoreExceptions);
+this.manager = Objects.requireNonNull(manager, "Redis Manager");
+}
+
+/**
+ * Builds RedisAppender instances.
+ * @param  The type to build
+ */
+public static class Builder> extends 
AbstractAppender.Builder
+implements 
org.apache.logging.log4j.core.util.Builder {
+
+@PluginAttribute("keys")
+private String[] keys;
+
+@PluginAttribute(value = "host")
+@Required(message = "No Redis hostname provided")
+private String host;
+
+@PluginAttribute(value = "port")
+private int port;
+
+@PluginAttribute(value = "ssl")
+private boolean ssl = false;
+
+@SuppressWarnings("resource")
+@Override
+public RedisAppender build() {
+return new RedisAppender(getName(), getLayout(), getFilter(), 
isIgnoreExceptions(), getRedisManager());
+}
+
+public Charset getCharset() {
+if (getLayout() instanceof AbstractStringLayout) {
+return ((AbstractStringLayout) getLayout()).getCharset();
+} else {
+return Charset.defaultCharset();
+}
+}
+
+String[] getKeys() {
+return keys;
+}
+
+String getHost() {
+return host;
+}
+
+boolean getSsl() {
+return ssl;
+}
+
+int getPort() {
+return port;
+}
+
+public B withKeys(final String key) {
+this.keys = new String[]{key};
+return asBuilder();
+}
+
+public B withKeys(final String[] keys) {
+this.keys = keys;
+return asBuilder();
+}
+
+public B withHost(final String host) {
+this.host = host;
+return asBuilder();
+}
+
+public B withPort(final int port) {
+this.port = port;
+return asBuilder();
+}
+
+public B withSsl(final boolean ssl) {
+this.ssl = ssl;
+return asBuilder();
   

[GitHub] logging-log4j2 issue #204: Prevent test flakes

2018-08-08 Thread garydgregory
Github user garydgregory commented on the issue:

https://github.com/apache/logging-log4j2/pull/204
  
Rules rock :-)


---


[GitHub] logging-log4j2 pull request #206: [LOG4J2-2400] Initial implementation of Re...

2018-08-08 Thread cakofony
Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/206#discussion_r208730159
  
--- Diff: 
log4j-redis/src/main/java/org/apache/logging/log4j/redis/appender/RedisManager.java
 ---
@@ -0,0 +1,86 @@
+package org.apache.logging.log4j.redis.appender;
+
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.AbstractManager;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.JedisPoolConfig;
+import redis.clients.jedis.exceptions.JedisConnectionException;
+
+import java.nio.charset.Charset;
+import java.util.concurrent.TimeUnit;
+
+class RedisManager extends AbstractManager {
+
+private final byte[][] byteKeys;
+private final String host;
+private final int port;
+private final Charset charset;
+private final boolean ssl;
+private JedisPool jedisPool;
+
+RedisManager(LoggerContext loggerContext, String name, String[] keys, 
String host, int port, boolean ssl, Charset charset) {
+super(loggerContext, name);
+this.byteKeys = new byte[keys.length][];
+for (int i = 0; i < keys.length; i++) {
+this.byteKeys[i] = keys[i].getBytes(charset);
+}
+this.charset = charset;
+this.host = host;
+this.port = port;
+this.ssl = ssl;
+}
+
+JedisPool createPool(String host, int port, boolean ssl) {
+JedisPoolConfig poolConfig = new JedisPoolConfig();
+poolConfig.setMaxIdle(5);
+poolConfig.setMinIdle(1);
+poolConfig.setTestOnBorrow(true);
+poolConfig.setTestOnReturn(true);
+poolConfig.setTestWhileIdle(true);
+poolConfig.setNumTestsPerEvictionRun(10);
+poolConfig.setTimeBetweenEvictionRunsMillis(6);
+return new JedisPool(poolConfig, host, port, ssl);
--- End diff --

Can we make all the jedis pool config parameters configurable?


---


[jira] [Created] (LOG4J2-2402) NTEventLogAppender has security issues

2018-08-08 Thread Rolando Sanchez Villalobos (JIRA)
Rolando Sanchez Villalobos created LOG4J2-2402:
--

 Summary: NTEventLogAppender has security issues
 Key: LOG4J2-2402
 URL: https://issues.apache.org/jira/browse/LOG4J2-2402
 Project: Log4j 2
  Issue Type: Bug
  Components: Appenders
Affects Versions: 2.4.1
 Environment: Windows 2012 R2

Windows 2010
Reporter: Rolando Sanchez Villalobos


The NTEventLogAppender.amd64.dll was reviewed by security testers and showed 
the following issues

- Executable not signed or code signature missing. 
 - No Address Space Layout Randomization (ASLR).
 - Software Enforce Data Execution Prevention (DEP) Enabled.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2400) Support for log4j2 RedisAppender

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573795#comment-16573795
 ] 

ASF GitHub Bot commented on LOG4J2-2400:


GitHub user kmeurer opened a pull request:

https://github.com/apache/logging-log4j2/pull/206

[LOG4J2-2400] Initial implementation of RedisAppender. (#1)

This PR implements a dedicated RedisAppender in log4j2. More details can be 
found in the log4j2 ticket here: 
https://issues.apache.org/jira/projects/LOG4J2/issues/LOG4J2-2400?filter=allopenissues

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/kmeurer/logging-log4j2 master

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/logging-log4j2/pull/206.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #206


commit 93580513440963de03fb7322656ea129996fbd9c
Author: Kevin Meurer 
Date:   2018-08-08T20:03:07Z

[LOG4J2-2400] Initial implementation of RedisAppender. (#1)

* Initial implementation of Redis appender.

* Add unit test support for Redis Appender.

* Clean up implementation.

* Add site documentation and clean up imports.

commit cc409e205bcb612c6f5efe0ee81e91450006176e
Author: kmeurer 
Date:   2018-08-08T20:06:01Z

Merge branch 'master' of https://github.com/kmeurer/logging-log4j2




> Support for log4j2 RedisAppender
> 
>
> Key: LOG4J2-2400
> URL: https://issues.apache.org/jira/browse/LOG4J2-2400
> Project: Log4j 2
>  Issue Type: New Feature
>  Components: Appenders
>Reporter: Kevin Andrew Meurer
>Priority: Major
>
> Redis functions well as a temporary queue for event data en route to another 
> data store. For example, Redis may be used to improve the fault-tolerance of 
> a logging pipeline by serving as an intermediary as log events move to a 
> separate storage layer (i.e. log4j2 - > Redis < - Logstash -> Elasticsearch).
> As a result, event processing applications may wish to use Redis instead of 
> Kafka as a message broker. We should add support for a RedisAppender to 
> support this use case.
> Relevant dev list thread: 
> [https://lists.apache.org/thread.html/4967cf3cd4db367ba563143ccd1438b7c53830671881eb692642b8d9@%3Cdev.logging.apache.org%3E]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] logging-log4j2 pull request #206: [LOG4J2-2400] Initial implementation of Re...

2018-08-08 Thread kmeurer
GitHub user kmeurer opened a pull request:

https://github.com/apache/logging-log4j2/pull/206

[LOG4J2-2400] Initial implementation of RedisAppender. (#1)

This PR implements a dedicated RedisAppender in log4j2. More details can be 
found in the log4j2 ticket here: 
https://issues.apache.org/jira/projects/LOG4J2/issues/LOG4J2-2400?filter=allopenissues

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/kmeurer/logging-log4j2 master

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/logging-log4j2/pull/206.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #206


commit 93580513440963de03fb7322656ea129996fbd9c
Author: Kevin Meurer 
Date:   2018-08-08T20:03:07Z

[LOG4J2-2400] Initial implementation of RedisAppender. (#1)

* Initial implementation of Redis appender.

* Add unit test support for Redis Appender.

* Clean up implementation.

* Add site documentation and clean up imports.

commit cc409e205bcb612c6f5efe0ee81e91450006176e
Author: kmeurer 
Date:   2018-08-08T20:06:01Z

Merge branch 'master' of https://github.com/kmeurer/logging-log4j2




---


[jira] [Commented] (LOG4J2-2399) Reusable Messages do not respect log4j.format.msg.async

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573741#comment-16573741
 ] 

ASF GitHub Bot commented on LOG4J2-2399:


Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/205#discussion_r208705419
  
--- Diff: 
log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
 ---
@@ -204,15 +206,19 @@ public void setLoggerName(final String loggerName) {
 @Override
 public Message getMessage() {
 if (message == null) {
-return messageText == null ? EMPTY : this;
+return (messageText == null && messageContentFormatter == 
null) ? EMPTY : this;
 }
 return message;
 }
 
 public void setMessage(final Message msg) {
 if (msg instanceof ReusableMessage) {
 final ReusableMessage reusable = (ReusableMessage) msg;
-reusable.formatTo(getMessageTextForWriting());
+if (Constants.FORMAT_MESSAGES_IN_BACKGROUND && msg instanceof 
MessageContentFormatterProvider) {
+this.messageContentFormatter = 
((MessageContentFormatterProvider) msg).getMessageContentFormatter();
--- End diff --

I don't think this quite works for the AsyncLogger case. Using mixed 
sync/async loggers via configuration, message data flows:

1. ReusableMessage.init()
2. MutableLogEvent.initFrom()
3. MutableLogEvent may be logged to synchronous appenders, then data is 
copied to the background thread for asynchronous format/append operations. This 
is done by initializing another MutableLogEvent (on the disruptor ringbuffer) 
from the existing MutableLogEvent, see AsyncLoggerConfigDisruptor:174.

We can fix this by making MutableLogEvent and RingBufferLogEvent both 
implement MessageContentFormatterProvider, and check `messageContentFormatter` 
for null in which case  `reusable.formatTo(getMessageTextForWriting());` should 
be invoked.


> Reusable Messages do not respect log4j.format.msg.async
> ---
>
> Key: LOG4J2-2399
> URL: https://issues.apache.org/jira/browse/LOG4J2-2399
> Project: Log4j 2
>  Issue Type: Task
>  Components: Core
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
>
> Setting "log4j.format.msg.async" applies only to messages that do not 
> implement ReusableMessage.
> On applications using asynchronous logging with message formatting in the 
> background there is a measurable performance cost to using 
> ReusableParameterizedMessages instead of ParameterizedMessages due to 
> formatting on the application thread 
> (MutableLogEvent/RingBufferLogEvent.setMessage).
> I have a custom layout which does not log formatted messages in most cases, 
> but the format string and parameter values separately in order to analyze 
> values logged over time bucketed by logger name and format string. In this 
> case the formatting is unnecessary work. It is possible to implement a custom 
> message factory which doesn't format message data, however that would break 
> the ability to add a standard pattern layout in addition to the custom 
> formatter.
> h2. Proposed Design
> Our reusable events (MutableLogEvent and RingBufferLogEvent) currently 
> capture most of the required information, the format string and parameter 
> array, but are missing a bit of context for how the original message 
> implementation would format that data.
> ReusableMessage implementations may optionally extend 
> "MessageContentFormatterProvider"
> {code:java}
> interface MessageContentFormatterProvider {
>   MessageContentFormatter getMessageContentFormatter();
> }{code}
> Where MessageContentFormatter takes the form:
> {code:java}
> interface MessageContentFormatter {
>   void appendTo(StringBuilder dest, String format, Object[] params, short 
> paramCount);
> }{code}
> Reusable log event implementations will be updated to hold a reference to the 
> content formatter (instead of formatting to the local event buffer) when 
> asynchronous formatting is enabled _and_ the message is an instance of 
> MessageContentFormatterProvider.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2399) Reusable Messages do not respect log4j.format.msg.async

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573740#comment-16573740
 ] 

ASF GitHub Bot commented on LOG4J2-2399:


Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/205#discussion_r208702264
  
--- Diff: 
log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
 ---
@@ -355,4 +352,35 @@ public void clear() { // LOG4J2-1583
 messagePattern = null;
 throwable = null;
 }
+
+@Override
+public MessageContentFormatter getMessageContentFormatter() {
+return formatter;
+}
+
+private static final MessageContentFormatter formatter = new 
MessageContentFormatter() {
+private final ThreadLocal indices = new ThreadLocal<>();
--- End diff --

What happens to these values if nested logging occurs in 
ParameterFormatter.formatMessage2? See 
[LOG4J2-1583](https://issues.apache.org/jira/browse/LOG4J2-1583) referenced on 
`ReusableParameterizedMessage.reserved`. We should write a test for this case.


> Reusable Messages do not respect log4j.format.msg.async
> ---
>
> Key: LOG4J2-2399
> URL: https://issues.apache.org/jira/browse/LOG4J2-2399
> Project: Log4j 2
>  Issue Type: Task
>  Components: Core
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
>
> Setting "log4j.format.msg.async" applies only to messages that do not 
> implement ReusableMessage.
> On applications using asynchronous logging with message formatting in the 
> background there is a measurable performance cost to using 
> ReusableParameterizedMessages instead of ParameterizedMessages due to 
> formatting on the application thread 
> (MutableLogEvent/RingBufferLogEvent.setMessage).
> I have a custom layout which does not log formatted messages in most cases, 
> but the format string and parameter values separately in order to analyze 
> values logged over time bucketed by logger name and format string. In this 
> case the formatting is unnecessary work. It is possible to implement a custom 
> message factory which doesn't format message data, however that would break 
> the ability to add a standard pattern layout in addition to the custom 
> formatter.
> h2. Proposed Design
> Our reusable events (MutableLogEvent and RingBufferLogEvent) currently 
> capture most of the required information, the format string and parameter 
> array, but are missing a bit of context for how the original message 
> implementation would format that data.
> ReusableMessage implementations may optionally extend 
> "MessageContentFormatterProvider"
> {code:java}
> interface MessageContentFormatterProvider {
>   MessageContentFormatter getMessageContentFormatter();
> }{code}
> Where MessageContentFormatter takes the form:
> {code:java}
> interface MessageContentFormatter {
>   void appendTo(StringBuilder dest, String format, Object[] params, short 
> paramCount);
> }{code}
> Reusable log event implementations will be updated to hold a reference to the 
> content formatter (instead of formatting to the local event buffer) when 
> asynchronous formatting is enabled _and_ the message is an instance of 
> MessageContentFormatterProvider.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] logging-log4j2 pull request #205: [LOG4J2-2399] support for async formatting...

2018-08-08 Thread cakofony
Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/205#discussion_r208702264
  
--- Diff: 
log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
 ---
@@ -355,4 +352,35 @@ public void clear() { // LOG4J2-1583
 messagePattern = null;
 throwable = null;
 }
+
+@Override
+public MessageContentFormatter getMessageContentFormatter() {
+return formatter;
+}
+
+private static final MessageContentFormatter formatter = new 
MessageContentFormatter() {
+private final ThreadLocal indices = new ThreadLocal<>();
--- End diff --

What happens to these values if nested logging occurs in 
ParameterFormatter.formatMessage2? See 
[LOG4J2-1583](https://issues.apache.org/jira/browse/LOG4J2-1583) referenced on 
`ReusableParameterizedMessage.reserved`. We should write a test for this case.


---


[jira] [Commented] (LOG4J2-2399) Reusable Messages do not respect log4j.format.msg.async

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573739#comment-16573739
 ] 

ASF GitHub Bot commented on LOG4J2-2399:


Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/205#discussion_r208699061
  
--- Diff: 
log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
 ---
@@ -125,12 +123,23 @@ private void init(final String messagePattern, final 
int argCount, final Object[
 this.varargs = null;
 this.messagePattern = messagePattern;
 this.argCount = argCount;
-final int placeholderCount = count(messagePattern, indices);
-initThrowable(paramArray, argCount, placeholderCount);
-this.usedCount = Math.min(placeholderCount, argCount);
+
+int usedParams = count(messagePattern, null);
+if (usedParams < argCount && paramArray[argCount - 1] instanceof 
Throwable) {
+this.throwable = (Throwable) paramArray[argCount - 1];
+} else {
+this.throwable = null;
+}
--- End diff --

I wonder if we should check `argCount > 0 && paramArray[argCount - 1] 
instanceof Throwable` prior to invoking count? Could be worth a benchmark, 
either way one iteration over a format string isn't very expensive.


> Reusable Messages do not respect log4j.format.msg.async
> ---
>
> Key: LOG4J2-2399
> URL: https://issues.apache.org/jira/browse/LOG4J2-2399
> Project: Log4j 2
>  Issue Type: Task
>  Components: Core
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
>
> Setting "log4j.format.msg.async" applies only to messages that do not 
> implement ReusableMessage.
> On applications using asynchronous logging with message formatting in the 
> background there is a measurable performance cost to using 
> ReusableParameterizedMessages instead of ParameterizedMessages due to 
> formatting on the application thread 
> (MutableLogEvent/RingBufferLogEvent.setMessage).
> I have a custom layout which does not log formatted messages in most cases, 
> but the format string and parameter values separately in order to analyze 
> values logged over time bucketed by logger name and format string. In this 
> case the formatting is unnecessary work. It is possible to implement a custom 
> message factory which doesn't format message data, however that would break 
> the ability to add a standard pattern layout in addition to the custom 
> formatter.
> h2. Proposed Design
> Our reusable events (MutableLogEvent and RingBufferLogEvent) currently 
> capture most of the required information, the format string and parameter 
> array, but are missing a bit of context for how the original message 
> implementation would format that data.
> ReusableMessage implementations may optionally extend 
> "MessageContentFormatterProvider"
> {code:java}
> interface MessageContentFormatterProvider {
>   MessageContentFormatter getMessageContentFormatter();
> }{code}
> Where MessageContentFormatter takes the form:
> {code:java}
> interface MessageContentFormatter {
>   void appendTo(StringBuilder dest, String format, Object[] params, short 
> paramCount);
> }{code}
> Reusable log event implementations will be updated to hold a reference to the 
> content formatter (instead of formatting to the local event buffer) when 
> asynchronous formatting is enabled _and_ the message is an instance of 
> MessageContentFormatterProvider.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2399) Reusable Messages do not respect log4j.format.msg.async

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573738#comment-16573738
 ] 

ASF GitHub Bot commented on LOG4J2-2399:


Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/205#discussion_r208700750
  
--- Diff: 
log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
 ---
@@ -355,4 +352,35 @@ public void clear() { // LOG4J2-1583
 messagePattern = null;
 throwable = null;
 }
+
+@Override
+public MessageContentFormatter getMessageContentFormatter() {
+return formatter;
+}
+
+private static final MessageContentFormatter formatter = new 
MessageContentFormatter() {
+private final ThreadLocal indices = new ThreadLocal<>();
+
+private int computeIndices(String messagePattern) {
+int[] result = indices.get();
+if (result == null) {
+result = new int[256];
+indices.set(result);
+}
+return ReusableParameterizedMessage.count(messagePattern, 
result);
+}
+
+@Override
+public void formatTo(String formatString, Object[] parameters, int 
parameterCount, StringBuilder buffer) {
+int placeholderCount = computeIndices(formatString);
+int usedCount = Math.min(placeholderCount, parameterCount);
+int[] computedIndices = indices.get();
--- End diff --

Can we avoid the second `ThreadLocal.get` here? Might be easiest if we do 
the logic from `computeIndices` in this method 


> Reusable Messages do not respect log4j.format.msg.async
> ---
>
> Key: LOG4J2-2399
> URL: https://issues.apache.org/jira/browse/LOG4J2-2399
> Project: Log4j 2
>  Issue Type: Task
>  Components: Core
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
>
> Setting "log4j.format.msg.async" applies only to messages that do not 
> implement ReusableMessage.
> On applications using asynchronous logging with message formatting in the 
> background there is a measurable performance cost to using 
> ReusableParameterizedMessages instead of ParameterizedMessages due to 
> formatting on the application thread 
> (MutableLogEvent/RingBufferLogEvent.setMessage).
> I have a custom layout which does not log formatted messages in most cases, 
> but the format string and parameter values separately in order to analyze 
> values logged over time bucketed by logger name and format string. In this 
> case the formatting is unnecessary work. It is possible to implement a custom 
> message factory which doesn't format message data, however that would break 
> the ability to add a standard pattern layout in addition to the custom 
> formatter.
> h2. Proposed Design
> Our reusable events (MutableLogEvent and RingBufferLogEvent) currently 
> capture most of the required information, the format string and parameter 
> array, but are missing a bit of context for how the original message 
> implementation would format that data.
> ReusableMessage implementations may optionally extend 
> "MessageContentFormatterProvider"
> {code:java}
> interface MessageContentFormatterProvider {
>   MessageContentFormatter getMessageContentFormatter();
> }{code}
> Where MessageContentFormatter takes the form:
> {code:java}
> interface MessageContentFormatter {
>   void appendTo(StringBuilder dest, String format, Object[] params, short 
> paramCount);
> }{code}
> Reusable log event implementations will be updated to hold a reference to the 
> content formatter (instead of formatting to the local event buffer) when 
> asynchronous formatting is enabled _and_ the message is an instance of 
> MessageContentFormatterProvider.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] logging-log4j2 pull request #205: [LOG4J2-2399] support for async formatting...

2018-08-08 Thread cakofony
Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/205#discussion_r208699061
  
--- Diff: 
log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
 ---
@@ -125,12 +123,23 @@ private void init(final String messagePattern, final 
int argCount, final Object[
 this.varargs = null;
 this.messagePattern = messagePattern;
 this.argCount = argCount;
-final int placeholderCount = count(messagePattern, indices);
-initThrowable(paramArray, argCount, placeholderCount);
-this.usedCount = Math.min(placeholderCount, argCount);
+
+int usedParams = count(messagePattern, null);
+if (usedParams < argCount && paramArray[argCount - 1] instanceof 
Throwable) {
+this.throwable = (Throwable) paramArray[argCount - 1];
+} else {
+this.throwable = null;
+}
--- End diff --

I wonder if we should check `argCount > 0 && paramArray[argCount - 1] 
instanceof Throwable` prior to invoking count? Could be worth a benchmark, 
either way one iteration over a format string isn't very expensive.


---


[GitHub] logging-log4j2 pull request #205: [LOG4J2-2399] support for async formatting...

2018-08-08 Thread cakofony
Github user cakofony commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/205#discussion_r208700750
  
--- Diff: 
log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
 ---
@@ -355,4 +352,35 @@ public void clear() { // LOG4J2-1583
 messagePattern = null;
 throwable = null;
 }
+
+@Override
+public MessageContentFormatter getMessageContentFormatter() {
+return formatter;
+}
+
+private static final MessageContentFormatter formatter = new 
MessageContentFormatter() {
+private final ThreadLocal indices = new ThreadLocal<>();
+
+private int computeIndices(String messagePattern) {
+int[] result = indices.get();
+if (result == null) {
+result = new int[256];
+indices.set(result);
+}
+return ReusableParameterizedMessage.count(messagePattern, 
result);
+}
+
+@Override
+public void formatTo(String formatString, Object[] parameters, int 
parameterCount, StringBuilder buffer) {
+int placeholderCount = computeIndices(formatString);
+int usedCount = Math.min(placeholderCount, parameterCount);
+int[] computedIndices = indices.get();
--- End diff --

Can we avoid the second `ThreadLocal.get` here? Might be easiest if we do 
the logic from `computeIndices` in this method 


---


[jira] [Commented] (LOG4J2-2363) ReusableObjectMessage does not pass object parameter to reusable events

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2363?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573697#comment-16573697
 ] 

ASF GitHub Bot commented on LOG4J2-2363:


Github user asfgit closed the pull request at:

https://github.com/apache/logging-log4j2/pull/203


> ReusableObjectMessage does not pass object parameter to reusable events
> ---
>
> Key: LOG4J2-2363
> URL: https://issues.apache.org/jira/browse/LOG4J2-2363
> Project: Log4j 2
>  Issue Type: Improvement
>  Components: Core
>Affects Versions: 2.11.0, 2.11.1
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
> Fix For: 3.0.0, 2.11.2
>
>
> swapParameters returns the unmodified input array. Implementations of 
> swapParameters should agree with the value returned from getParameters.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] logging-log4j2 pull request #203: [LOG4J2-2363] pass object parameter to reu...

2018-08-08 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/logging-log4j2/pull/203


---


[jira] [Commented] (LOG4J2-2363) ReusableObjectMessage does not pass object parameter to reusable events

2018-08-08 Thread ASF subversion and git services (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2363?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573682#comment-16573682
 ] 

ASF subversion and git services commented on LOG4J2-2363:
-

Commit bc829e47c43a07f86173aceb4108adcdfacfba51 in logging-log4j2's branch 
refs/heads/release-2.x from Brian Laub
[ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=bc829e4 ]

[LOG4J2-2363] pass object parameter to reusable events

make ReusableObjectMessage always pass its object as the first parameter

This closes #205


> ReusableObjectMessage does not pass object parameter to reusable events
> ---
>
> Key: LOG4J2-2363
> URL: https://issues.apache.org/jira/browse/LOG4J2-2363
> Project: Log4j 2
>  Issue Type: Improvement
>  Components: Core
>Affects Versions: 2.11.0, 2.11.1
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
> Fix For: 3.0.0, 2.11.2
>
>
> swapParameters returns the unmodified input array. Implementations of 
> swapParameters should agree with the value returned from getParameters.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2399) Reusable Messages do not respect log4j.format.msg.async

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573680#comment-16573680
 ] 

ASF GitHub Bot commented on LOG4J2-2399:


Github user asfgit closed the pull request at:

https://github.com/apache/logging-log4j2/pull/205


> Reusable Messages do not respect log4j.format.msg.async
> ---
>
> Key: LOG4J2-2399
> URL: https://issues.apache.org/jira/browse/LOG4J2-2399
> Project: Log4j 2
>  Issue Type: Task
>  Components: Core
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
>
> Setting "log4j.format.msg.async" applies only to messages that do not 
> implement ReusableMessage.
> On applications using asynchronous logging with message formatting in the 
> background there is a measurable performance cost to using 
> ReusableParameterizedMessages instead of ParameterizedMessages due to 
> formatting on the application thread 
> (MutableLogEvent/RingBufferLogEvent.setMessage).
> I have a custom layout which does not log formatted messages in most cases, 
> but the format string and parameter values separately in order to analyze 
> values logged over time bucketed by logger name and format string. In this 
> case the formatting is unnecessary work. It is possible to implement a custom 
> message factory which doesn't format message data, however that would break 
> the ability to add a standard pattern layout in addition to the custom 
> formatter.
> h2. Proposed Design
> Our reusable events (MutableLogEvent and RingBufferLogEvent) currently 
> capture most of the required information, the format string and parameter 
> array, but are missing a bit of context for how the original message 
> implementation would format that data.
> ReusableMessage implementations may optionally extend 
> "MessageContentFormatterProvider"
> {code:java}
> interface MessageContentFormatterProvider {
>   MessageContentFormatter getMessageContentFormatter();
> }{code}
> Where MessageContentFormatter takes the form:
> {code:java}
> interface MessageContentFormatter {
>   void appendTo(StringBuilder dest, String format, Object[] params, short 
> paramCount);
> }{code}
> Reusable log event implementations will be updated to hold a reference to the 
> content formatter (instead of formatting to the local event buffer) when 
> asynchronous formatting is enabled _and_ the message is an instance of 
> MessageContentFormatterProvider.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] logging-log4j2 pull request #205: [LOG4J2-2399] support for async formatting...

2018-08-08 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/logging-log4j2/pull/205


---


[jira] [Commented] (LOG4J2-2399) Reusable Messages do not respect log4j.format.msg.async

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573639#comment-16573639
 ] 

ASF GitHub Bot commented on LOG4J2-2399:


GitHub user bjlaub opened a pull request:

https://github.com/apache/logging-log4j2/pull/205

[LOG4J2-2399] support for async formatting on reusable messages

Adds support for deferring message content formatting on certain
ReusableMessage implementations to a background thread when async
logging is enabled. This change adds the ability for log events to
retain an instance of a formatter for a message so that the message
content can be formatted later, after the message has already been
recycled.

This is an effort to optimize performance for use cases where formatting
on the logging thread is unnecessary or undesired.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/bjlaub/logging-log4j2 
async-background-formatting

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/logging-log4j2/pull/205.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #205


commit ddae40953cfe24232f58f23e90a417623a260853
Author: Brian Laub 
Date:   2018-08-08T16:13:35Z

[LOG4J2-2399] support for async formatting on reusable messages

Adds support for deferring message content formatting on certain
ReusableMessage implementations to a background thread when async
logging is enabled. This change adds the ability for log events to
retain an instance of a formatter for a message so that the message
content can be formatted later, after the message has already been
recycled.

This is an effort to optimize performance for use cases where formatting
on the logging thread is unnecessary or undesired.




> Reusable Messages do not respect log4j.format.msg.async
> ---
>
> Key: LOG4J2-2399
> URL: https://issues.apache.org/jira/browse/LOG4J2-2399
> Project: Log4j 2
>  Issue Type: Task
>  Components: Core
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
>
> Setting "log4j.format.msg.async" applies only to messages that do not 
> implement ReusableMessage.
> On applications using asynchronous logging with message formatting in the 
> background there is a measurable performance cost to using 
> ReusableParameterizedMessages instead of ParameterizedMessages due to 
> formatting on the application thread 
> (MutableLogEvent/RingBufferLogEvent.setMessage).
> I have a custom layout which does not log formatted messages in most cases, 
> but the format string and parameter values separately in order to analyze 
> values logged over time bucketed by logger name and format string. In this 
> case the formatting is unnecessary work. It is possible to implement a custom 
> message factory which doesn't format message data, however that would break 
> the ability to add a standard pattern layout in addition to the custom 
> formatter.
> h2. Proposed Design
> Our reusable events (MutableLogEvent and RingBufferLogEvent) currently 
> capture most of the required information, the format string and parameter 
> array, but are missing a bit of context for how the original message 
> implementation would format that data.
> ReusableMessage implementations may optionally extend 
> "MessageContentFormatterProvider"
> {code:java}
> interface MessageContentFormatterProvider {
>   MessageContentFormatter getMessageContentFormatter();
> }{code}
> Where MessageContentFormatter takes the form:
> {code:java}
> interface MessageContentFormatter {
>   void appendTo(StringBuilder dest, String format, Object[] params, short 
> paramCount);
> }{code}
> Reusable log event implementations will be updated to hold a reference to the 
> content formatter (instead of formatting to the local event buffer) when 
> asynchronous formatting is enabled _and_ the message is an instance of 
> MessageContentFormatterProvider.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] logging-log4j2 pull request #205: [LOG4J2-2399] support for async formatting...

2018-08-08 Thread bjlaub
GitHub user bjlaub opened a pull request:

https://github.com/apache/logging-log4j2/pull/205

[LOG4J2-2399] support for async formatting on reusable messages

Adds support for deferring message content formatting on certain
ReusableMessage implementations to a background thread when async
logging is enabled. This change adds the ability for log events to
retain an instance of a formatter for a message so that the message
content can be formatted later, after the message has already been
recycled.

This is an effort to optimize performance for use cases where formatting
on the logging thread is unnecessary or undesired.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/bjlaub/logging-log4j2 
async-background-formatting

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/logging-log4j2/pull/205.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #205


commit ddae40953cfe24232f58f23e90a417623a260853
Author: Brian Laub 
Date:   2018-08-08T16:13:35Z

[LOG4J2-2399] support for async formatting on reusable messages

Adds support for deferring message content formatting on certain
ReusableMessage implementations to a background thread when async
logging is enabled. This change adds the ability for log events to
retain an instance of a formatter for a message so that the message
content can be formatted later, after the message has already been
recycled.

This is an effort to optimize performance for use cases where formatting
on the logging thread is unnecessary or undesired.




---


[jira] [Commented] (LOG4J2-2363) ReusableObjectMessage does not pass object parameter to reusable events

2018-08-08 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2363?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16573577#comment-16573577
 ] 

ASF GitHub Bot commented on LOG4J2-2363:


Github user bjlaub commented on a diff in the pull request:

https://github.com/apache/logging-log4j2/pull/203#discussion_r208674028
  
--- Diff: 
log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
 ---
@@ -100,16 +100,17 @@ public Throwable getThrowable() {
  */
 @Override
 public Object[] swapParameters(final Object[] emptyReplacement) {
+emptyReplacement[0] = obj;
--- End diff --

@cakofony fixed


> ReusableObjectMessage does not pass object parameter to reusable events
> ---
>
> Key: LOG4J2-2363
> URL: https://issues.apache.org/jira/browse/LOG4J2-2363
> Project: Log4j 2
>  Issue Type: Improvement
>  Components: Core
>Affects Versions: 2.11.0, 2.11.1
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
> Fix For: 3.0.0, 2.11.2
>
>
> swapParameters returns the unmodified input array. Implementations of 
> swapParameters should agree with the value returned from getParameters.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] logging-log4j2 issue #204: Prevent test flakes

2018-08-08 Thread cakofony
Github user cakofony commented on the issue:

https://github.com/apache/logging-log4j2/pull/204
  
merged


---


[GitHub] logging-log4j2 pull request #203: [LOG4J2-2363] pass object parameter to reu...

2018-08-08 Thread bjlaub
GitHub user bjlaub opened a pull request:

https://github.com/apache/logging-log4j2/pull/203

[LOG4J2-2363] pass object parameter to reusable events

make ReusableObjectMessage always pass its object as the first parameter

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/bjlaub/logging-log4j2 
fix-reusable-object-message

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/logging-log4j2/pull/203.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #203


commit 4bbdf98b55be8731e067f44aec7a10122c75ce68
Author: Brian Laub 
Date:   2018-08-08T16:16:30Z

[LOG4J2-2363] pass object parameter to reusable events

make ReusableObjectMessage always pass its object as the first parameter




---


[jira] [Updated] (LOG4J2-2363) ReusableObjectMessage does not pass object parameter to reusable events

2018-08-08 Thread Carter Kozak (JIRA)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-2363?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Carter Kozak updated LOG4J2-2363:
-
Fix Version/s: 2.11.2

> ReusableObjectMessage does not pass object parameter to reusable events
> ---
>
> Key: LOG4J2-2363
> URL: https://issues.apache.org/jira/browse/LOG4J2-2363
> Project: Log4j 2
>  Issue Type: Improvement
>  Components: Core
>Affects Versions: 2.11.0, 2.11.1
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
> Fix For: 3.0.0, 2.11.2
>
>
> swapParameters returns the unmodified input array. Implementations of 
> swapParameters should agree with the value returned from getParameters.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (LOG4J2-2363) ReusableObjectMessage does not pass object parameter to reusable events

2018-08-08 Thread Carter Kozak (JIRA)


 [ 
https://issues.apache.org/jira/browse/LOG4J2-2363?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Carter Kozak updated LOG4J2-2363:
-
Affects Version/s: 2.11.1

> ReusableObjectMessage does not pass object parameter to reusable events
> ---
>
> Key: LOG4J2-2363
> URL: https://issues.apache.org/jira/browse/LOG4J2-2363
> Project: Log4j 2
>  Issue Type: Improvement
>  Components: Core
>Affects Versions: 2.11.0, 2.11.1
>Reporter: Carter Kozak
>Assignee: Carter Kozak
>Priority: Major
> Fix For: 3.0.0, 2.11.2
>
>
> swapParameters returns the unmodified input array. Implementations of 
> swapParameters should agree with the value returned from getParameters.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)