[ 
https://issues.apache.org/jira/browse/LOG4J2-2400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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<? extends 
Serializable> 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 <B> The type to build
    +     */
    +    public static class Builder<B extends Builder<B>> extends 
AbstractAppender.Builder<B>
    +            implements 
org.apache.logging.log4j.core.util.Builder<RedisAppender> {
    +
    +        @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
>          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)

Reply via email to