Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.1.0-incubating
    • Fix Version/s: 4.1.0-incubating
    • Component/s: None
    • Labels:
    • Environment:
      jdk7

      Description

      As Rocketmq is widely used,A log appender is also necessary.

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user lindzh opened a pull request:

          https://github.com/apache/incubator-rocketmq/pull/101

          ROCKETMQ-194 log appender support

          As Rocketmq is widely used,A log appender is also necessary.

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

          $ git pull https://github.com/lindzh/incubator-rocketmq log_appender

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

          https://github.com/apache/incubator-rocketmq/pull/101.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 #101



          Show
          githubbot ASF GitHub Bot added a comment - GitHub user lindzh opened a pull request: https://github.com/apache/incubator-rocketmq/pull/101 ROCKETMQ-194 log appender support As Rocketmq is widely used,A log appender is also necessary. You can merge this pull request into a Git repository by running: $ git pull https://github.com/lindzh/incubator-rocketmq log_appender Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-rocketmq/pull/101.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 #101
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115472312

          — Diff: logappender/pom.xml —
          @@ -0,0 +1,122 @@
          +<?xml version="1.0" encoding="UTF-8"?>
          +<!--
          + Licensed to the Apache Software Foundation (ASF) under one or more
          + contributor license agreements. See the NOTICE file distributed with
          + this work for additional information regarding copyright ownership.
          + The ASF licenses this file to You under the Apache License, Version 2.0
          + (the "License"); you may not use this file except in compliance with
          + the License. You may obtain a copy of the License at
          +
          + http://www.apache.org/licenses/LICENSE-2.0
          +
          + Unless required by applicable law or agreed to in writing, software
          + distributed under the License is distributed on an "AS IS" BASIS,
          + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
          + See the License for the specific language governing permissions and
          + limitations under the License.
          + -->
          +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          + <parent>
          + <groupId>org.apache.rocketmq</groupId>
          + <artifactId>rocketmq-all</artifactId>
          + <version>4.1.0-incubating-SNAPSHOT</version>
          + </parent>
          + <modelVersion>4.0.0</modelVersion>
          + <artifactId>rocketmq-logappender</artifactId>
          + <packaging>jar</packaging>
          + <name>rocketmq-logappender $

          {project.version}

          </name>
          +
          + <properties>
          + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          + <maven.test.skip>false</maven.test.skip>
          + <maven.javadoc.skip>true</maven.javadoc.skip>
          + <maven.compiler.source>1.7</maven.compiler.source>
          + <maven.compiler.target>1.7</maven.compiler.target>
          + </properties>
          +
          + <dependencies>
          +
          + <dependency>
          + <groupId>org.slf4j</groupId>
          + <artifactId>slf4j-api</artifactId>
          + <version>1.7.7</version>
          + <optional>true</optional>
          — End diff –

          We must consider the suitable dependency here.

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115472312 — Diff: logappender/pom.xml — @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> + <parent> + <groupId>org.apache.rocketmq</groupId> + <artifactId>rocketmq-all</artifactId> + <version>4.1.0-incubating-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>rocketmq-logappender</artifactId> + <packaging>jar</packaging> + <name>rocketmq-logappender $ {project.version} </name> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.test.skip>false</maven.test.skip> + <maven.javadoc.skip>true</maven.javadoc.skip> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.7</version> + <optional>true</optional> — End diff – We must consider the suitable dependency here.
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115471296

          — Diff: logappender/README.md —
          @@ -0,0 +1,64 @@
          +# RocketMQ-LogAppender [Unable to render embedded object: File ([Build Status](https://travis-ci.org/rocketmq/rocketmq-logappender.svg?branch=master)](https://travis-ci.org/rocketmq/rocketmq-logappender) [) not found.[Coverage Status](https://coveralls.io/repos/github/rocketmq/rocketmq-logappender/badge.svg?branch=master)](https://coveralls.io/github/rocketmq/rocketmq-logappender?branch=master)
          +
          +
          +## Introduction
          +RocketMQ-LogAppender is a logging component implement of log4j,log4j2 and logback.Taking Apache RocketMQ as broker.
          — End diff –

          What is "implement of " It's confused. IMO, this project is used to send log message using RocektMQ. while log4j, log4j2 and logback is just a adapter for SL4J

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115471296 — Diff: logappender/README.md — @@ -0,0 +1,64 @@ +# RocketMQ-LogAppender [ Unable to render embedded object: File ([Build Status]( https://travis-ci.org/rocketmq/rocketmq-logappender.svg?branch=master)](https://travis-ci.org/rocketmq/rocketmq-logappender ) [) not found. [Coverage Status] ( https://coveralls.io/repos/github/rocketmq/rocketmq-logappender/badge.svg?branch=master)](https://coveralls.io/github/rocketmq/rocketmq-logappender?branch=master ) + + +## Introduction +RocketMQ-LogAppender is a logging component implement of log4j,log4j2 and logback.Taking Apache RocketMQ as broker. — End diff – What is "implement of " It's confused. IMO, this project is used to send log message using RocektMQ. while log4j, log4j2 and logback is just a adapter for SL4J
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115471504

          — Diff: logappender/README.md —
          @@ -0,0 +1,64 @@
          +# RocketMQ-LogAppender [Unable to render embedded object: File ([Build Status](https://travis-ci.org/rocketmq/rocketmq-logappender.svg?branch=master)](https://travis-ci.org/rocketmq/rocketmq-logappender) [) not found.[Coverage Status](https://coveralls.io/repos/github/rocketmq/rocketmq-logappender/badge.svg?branch=master)](https://coveralls.io/github/rocketmq/rocketmq-logappender?branch=master)
          +
          +
          +## Introduction
          +RocketMQ-LogAppender is a logging component implement of log4j,log4j2 and logback.Taking Apache RocketMQ as broker.
          +All logs loged will be send to the topic you define.
          +
          +## Examples
          +
          +#### log4j example
          +
          +> config detail
          +
          +```xml
          +<appender name="mqAppender1" class="org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender">
          + <param name="Tag" value="log1" />
          — End diff –

          case-insensitive name ,right ?

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115471504 — Diff: logappender/README.md — @@ -0,0 +1,64 @@ +# RocketMQ-LogAppender [ Unable to render embedded object: File ([Build Status]( https://travis-ci.org/rocketmq/rocketmq-logappender.svg?branch=master)](https://travis-ci.org/rocketmq/rocketmq-logappender ) [) not found. [Coverage Status] ( https://coveralls.io/repos/github/rocketmq/rocketmq-logappender/badge.svg?branch=master)](https://coveralls.io/github/rocketmq/rocketmq-logappender?branch=master ) + + +## Introduction +RocketMQ-LogAppender is a logging component implement of log4j,log4j2 and logback.Taking Apache RocketMQ as broker. +All logs loged will be send to the topic you define. + +## Examples + +#### log4j example + +> config detail + +```xml +<appender name="mqAppender1" class="org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender"> + <param name="Tag" value="log1" /> — End diff – case-insensitive name ,right ?
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115473097

          — Diff: style/rmq_checkstyle.xml —
          @@ -30,6 +30,12 @@
          <!-- header -->
          <module name="RegexpHeader">
          <property name="header" value="/*\nLicensed to the Apache Software Foundation*"/>
          + <property name="fileExtensions" value="java"/>
          + </module>
          +
          + <module name="RegexpHeader">
          — End diff –

          Why change this rule~

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115473097 — Diff: style/rmq_checkstyle.xml — @@ -30,6 +30,12 @@ <!-- header --> <module name="RegexpHeader"> <property name="header" value="/*\nLicensed to the Apache Software Foundation*"/> + <property name="fileExtensions" value="java"/> + </module> + + <module name="RegexpHeader"> — End diff – Why change this rule~
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115470775

          — Diff: logappender/README.md —
          @@ -0,0 +1,64 @@
          +# RocketMQ-LogAppender [Unable to render embedded object: File ([Build Status](https://travis-ci.org/rocketmq/rocketmq-logappender.svg?branch=master)](https://travis-ci.org/rocketmq/rocketmq-logappender) [) not found.[Coverage Status](https://coveralls.io/repos/github/rocketmq/rocketmq-logappender/badge.svg?branch=master)](https://coveralls.io/github/rocketmq/rocketmq-logappender?branch=master)
          — End diff –

          Could we remove it if we want it into parent modue, we can reuse rocektmq existing infra.

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115470775 — Diff: logappender/README.md — @@ -0,0 +1,64 @@ +# RocketMQ-LogAppender [ Unable to render embedded object: File ([Build Status]( https://travis-ci.org/rocketmq/rocketmq-logappender.svg?branch=master)](https://travis-ci.org/rocketmq/rocketmq-logappender ) [) not found. [Coverage Status] ( https://coveralls.io/repos/github/rocketmq/rocketmq-logappender/badge.svg?branch=master)](https://coveralls.io/github/rocketmq/rocketmq-logappender?branch=master ) — End diff – Could we remove it if we want it into parent modue, we can reuse rocektmq existing infra.
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115471844

          — Diff: logappender/README.md —
          @@ -0,0 +1,64 @@
          +# RocketMQ-LogAppender [Unable to render embedded object: File ([Build Status](https://travis-ci.org/rocketmq/rocketmq-logappender.svg?branch=master)](https://travis-ci.org/rocketmq/rocketmq-logappender) [) not found.[Coverage Status](https://coveralls.io/repos/github/rocketmq/rocketmq-logappender/badge.svg?branch=master)](https://coveralls.io/github/rocketmq/rocketmq-logappender?branch=master)
          +
          +
          +## Introduction
          +RocketMQ-LogAppender is a logging component implement of log4j,log4j2 and logback.Taking Apache RocketMQ as broker.
          +All logs loged will be send to the topic you define.
          +
          +## Examples
          +
          +#### log4j example
          +
          +> config detail
          +
          +```xml
          +<appender name="mqAppender1" class="org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender">
          + <param name="Tag" value="log1" />
          + <param name="Topic" value="TopicTest" />
          + <param name="ProducerGroup" value="log4jxml" />
          + <param name="NameServerAddress" value="127.0.0.1:9876"/>
          + <layout class="org.apache.log4j.PatternLayout">
          + <param name="ConversionPattern" value="%d

          {yyyy-MM-dd HH:mm:ss}

          -%p %t %c - %m%n" />
          + </layout>
          +</appender>
          +
          +<appender name="mqAsyncAppender1" class="org.apache.log4j.AsyncAppender">
          + <param name="BufferSize" value="1024" />
          + <param name="Blocking" value="false" />
          + <appender-ref ref="mqAppender1"></appender-ref>
          +</appender>
          +
          +<logger name="testLogger" additivity="false">
          + <level value="INFO" />
          + <appender-ref ref="mqAsyncAppender1" />
          +</logger>
          +
          +```
          +
          +#### logback example
          +
          +```xml
          +<appender name="mqAppender1" class="org.apache.rocketmq.logappender.logback.RocketmqLogbackAppender">
          + <tag>log1</tag>
          + <topic>TopicTest</topic>
          + <producerGroup>logback</producerGroup>
          + <nameServerAddress>127.0.0.1:9876</nameServerAddress>
          + <layout>
          + <pattern>%date %p %t - %m%n</pattern>
          + </layout>
          +</appender>
          +
          +<appender name="mqAsyncAppender1" class="ch.qos.logback.classic.AsyncAppender">
          + <queueSize>1024</queueSize>
          + <discardingThreshold>80</discardingThreshold>
          + <maxFlushTime>2000</maxFlushTime>
          + <neverBlock>true</neverBlock>
          + <appender-ref ref="mqAppender1"/>
          +</appender>
          +<logger name="testLogger" level="debug" additivity="false">
          + <appender-ref ref="mqAsyncAppender1"/>
          +</logger>
          +
          +```
          +
          +More example,like log4j2,please see Test case.
          — End diff –

          Could we give the example link for user ?

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115471844 — Diff: logappender/README.md — @@ -0,0 +1,64 @@ +# RocketMQ-LogAppender [ Unable to render embedded object: File ([Build Status]( https://travis-ci.org/rocketmq/rocketmq-logappender.svg?branch=master)](https://travis-ci.org/rocketmq/rocketmq-logappender ) [) not found. [Coverage Status] ( https://coveralls.io/repos/github/rocketmq/rocketmq-logappender/badge.svg?branch=master)](https://coveralls.io/github/rocketmq/rocketmq-logappender?branch=master ) + + +## Introduction +RocketMQ-LogAppender is a logging component implement of log4j,log4j2 and logback.Taking Apache RocketMQ as broker. +All logs loged will be send to the topic you define. + +## Examples + +#### log4j example + +> config detail + +```xml +<appender name="mqAppender1" class="org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender"> + <param name="Tag" value="log1" /> + <param name="Topic" value="TopicTest" /> + <param name="ProducerGroup" value="log4jxml" /> + <param name="NameServerAddress" value="127.0.0.1:9876"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="%d {yyyy-MM-dd HH:mm:ss} -%p %t %c - %m%n" /> + </layout> +</appender> + +<appender name="mqAsyncAppender1" class="org.apache.log4j.AsyncAppender"> + <param name="BufferSize" value="1024" /> + <param name="Blocking" value="false" /> + <appender-ref ref="mqAppender1"></appender-ref> +</appender> + +<logger name="testLogger" additivity="false"> + <level value="INFO" /> + <appender-ref ref="mqAsyncAppender1" /> +</logger> + +``` + +#### logback example + +```xml +<appender name="mqAppender1" class="org.apache.rocketmq.logappender.logback.RocketmqLogbackAppender"> + <tag>log1</tag> + <topic>TopicTest</topic> + <producerGroup>logback</producerGroup> + <nameServerAddress>127.0.0.1:9876</nameServerAddress> + <layout> + <pattern>%date %p %t - %m%n</pattern> + </layout> +</appender> + +<appender name="mqAsyncAppender1" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>1024</queueSize> + <discardingThreshold>80</discardingThreshold> + <maxFlushTime>2000</maxFlushTime> + <neverBlock>true</neverBlock> + <appender-ref ref="mqAppender1"/> +</appender> +<logger name="testLogger" level="debug" additivity="false"> + <appender-ref ref="mqAsyncAppender1"/> +</logger> + +``` + +More example,like log4j2,please see Test case. — End diff – Could we give the example link for user ?
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115472704

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j/RocketmqLog4jAppender.java —
          @@ -0,0 +1,193 @@
          +/*
          + * 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.rocketmq.logappender.log4j;
          +
          +import org.apache.rocketmq.common.message.Message;
          +import org.apache.rocketmq.logappender.common.ProducerInstance;
          +import org.apache.log4j.AppenderSkeleton;
          +import org.apache.log4j.helpers.LogLog;
          +import org.apache.log4j.spi.ErrorCode;
          +import org.apache.log4j.spi.LoggingEvent;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +/**
          + * Log4j Appender Component
          + */
          +public class RocketmqLog4jAppender extends AppenderSkeleton {
          +
          + /**
          + * appended message tag define
          — End diff –

          Capitalize the first letter~

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115472704 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j/RocketmqLog4jAppender.java — @@ -0,0 +1,193 @@ +/* + * 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.rocketmq.logappender.log4j; + +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.logappender.common.ProducerInstance; +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.helpers.LogLog; +import org.apache.log4j.spi.ErrorCode; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.rocketmq.client.producer.MQProducer; + +/** + * Log4j Appender Component + */ +public class RocketmqLog4jAppender extends AppenderSkeleton { + + /** + * appended message tag define — End diff – Capitalize the first letter~
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115472199

          — Diff: logappender/pom.xml —
          @@ -0,0 +1,122 @@
          +<?xml version="1.0" encoding="UTF-8"?>
          +<!--
          + Licensed to the Apache Software Foundation (ASF) under one or more
          + contributor license agreements. See the NOTICE file distributed with
          + this work for additional information regarding copyright ownership.
          + The ASF licenses this file to You under the Apache License, Version 2.0
          + (the "License"); you may not use this file except in compliance with
          + the License. You may obtain a copy of the License at
          +
          + http://www.apache.org/licenses/LICENSE-2.0
          +
          + Unless required by applicable law or agreed to in writing, software
          + distributed under the License is distributed on an "AS IS" BASIS,
          + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
          + See the License for the specific language governing permissions and
          + limitations under the License.
          + -->
          +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          + <parent>
          + <groupId>org.apache.rocketmq</groupId>
          + <artifactId>rocketmq-all</artifactId>
          + <version>4.1.0-incubating-SNAPSHOT</version>
          + </parent>
          + <modelVersion>4.0.0</modelVersion>
          + <artifactId>rocketmq-logappender</artifactId>
          + <packaging>jar</packaging>
          + <name>rocketmq-logappender $

          {project.version}

          </name>
          +
          + <properties>
          + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          + <maven.test.skip>false</maven.test.skip>
          + <maven.javadoc.skip>true</maven.javadoc.skip>
          + <maven.compiler.source>1.7</maven.compiler.source>
          + <maven.compiler.target>1.7</maven.compiler.target>
          + </properties>
          +
          + <dependencies>
          +
          + <dependency>
          + <groupId>org.slf4j</groupId>
          + <artifactId>slf4j-api</artifactId>
          + <version>1.7.7</version>
          + <optional>true</optional>
          + </dependency>
          +
          + <dependency>
          + <groupId>log4j</groupId>
          + <artifactId>log4j</artifactId>
          + <version>1.2.17</version>
          + <optional>true</optional>
          + </dependency>
          +
          + <dependency>
          + <groupId>org.apache.logging.log4j</groupId>
          + <artifactId>log4j-core</artifactId>
          + <version>2.7</version>
          + <optional>true</optional>
          + </dependency>
          +
          +
          + <dependency>
          + <groupId>ch.qos.logback</groupId>
          + <artifactId>logback-core</artifactId>
          + <version>1.1.2</version>
          — End diff –

          The latest version ?

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115472199 — Diff: logappender/pom.xml — @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> + <parent> + <groupId>org.apache.rocketmq</groupId> + <artifactId>rocketmq-all</artifactId> + <version>4.1.0-incubating-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>rocketmq-logappender</artifactId> + <packaging>jar</packaging> + <name>rocketmq-logappender $ {project.version} </name> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.test.skip>false</maven.test.skip> + <maven.javadoc.skip>true</maven.javadoc.skip> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + </properties> + + <dependencies> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.7</version> + <optional>true</optional> + </dependency> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.17</version> + <optional>true</optional> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.7</version> + <optional>true</optional> + </dependency> + + + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>1.1.2</version> — End diff – The latest version ?
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115472087

          — Diff: logappender/pom.xml —
          @@ -0,0 +1,122 @@
          +<?xml version="1.0" encoding="UTF-8"?>
          +<!--
          + Licensed to the Apache Software Foundation (ASF) under one or more
          + contributor license agreements. See the NOTICE file distributed with
          + this work for additional information regarding copyright ownership.
          + The ASF licenses this file to You under the Apache License, Version 2.0
          + (the "License"); you may not use this file except in compliance with
          + the License. You may obtain a copy of the License at
          +
          + http://www.apache.org/licenses/LICENSE-2.0
          +
          + Unless required by applicable law or agreed to in writing, software
          + distributed under the License is distributed on an "AS IS" BASIS,
          + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
          + See the License for the specific language governing permissions and
          + limitations under the License.
          + -->
          +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          + <parent>
          + <groupId>org.apache.rocketmq</groupId>
          + <artifactId>rocketmq-all</artifactId>
          + <version>4.1.0-incubating-SNAPSHOT</version>
          + </parent>
          + <modelVersion>4.0.0</modelVersion>
          + <artifactId>rocketmq-logappender</artifactId>
          + <packaging>jar</packaging>
          + <name>rocketmq-logappender $

          {project.version}

          </name>
          +
          + <properties>
          + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          + <maven.test.skip>false</maven.test.skip>
          — End diff –

          Redundant config. we can extend from parent module.

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115472087 — Diff: logappender/pom.xml — @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> + <parent> + <groupId>org.apache.rocketmq</groupId> + <artifactId>rocketmq-all</artifactId> + <version>4.1.0-incubating-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>rocketmq-logappender</artifactId> + <packaging>jar</packaging> + <name>rocketmq-logappender $ {project.version} </name> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.test.skip>false</maven.test.skip> — End diff – Redundant config. we can extend from parent module.
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115471708

          — Diff: logappender/README.md —
          @@ -0,0 +1,64 @@
          +# RocketMQ-LogAppender [Unable to render embedded object: File ([Build Status](https://travis-ci.org/rocketmq/rocketmq-logappender.svg?branch=master)](https://travis-ci.org/rocketmq/rocketmq-logappender) [) not found.[Coverage Status](https://coveralls.io/repos/github/rocketmq/rocketmq-logappender/badge.svg?branch=master)](https://coveralls.io/github/rocketmq/rocketmq-logappender?branch=master)
          +
          +
          +## Introduction
          +RocketMQ-LogAppender is a logging component implement of log4j,log4j2 and logback.Taking Apache RocketMQ as broker.
          +All logs loged will be send to the topic you define.
          +
          +## Examples
          +
          +#### log4j example
          +
          +> config detail
          +
          +```xml
          +<appender name="mqAppender1" class="org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender">
          + <param name="Tag" value="log1" />
          + <param name="Topic" value="TopicTest" />
          + <param name="ProducerGroup" value="log4jxml" />
          + <param name="NameServerAddress" value="127.0.0.1:9876"/>
          + <layout class="org.apache.log4j.PatternLayout">
          + <param name="ConversionPattern" value="%d

          {yyyy-MM-dd HH:mm:ss}

          -%p %t %c - %m%n" />
          + </layout>
          +</appender>
          +
          +<appender name="mqAsyncAppender1" class="org.apache.log4j.AsyncAppender">
          + <param name="BufferSize" value="1024" />
          + <param name="Blocking" value="false" />
          + <appender-ref ref="mqAppender1"></appender-ref>
          — End diff –

          why not use single label as above?

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115471708 — Diff: logappender/README.md — @@ -0,0 +1,64 @@ +# RocketMQ-LogAppender [ Unable to render embedded object: File ([Build Status]( https://travis-ci.org/rocketmq/rocketmq-logappender.svg?branch=master)](https://travis-ci.org/rocketmq/rocketmq-logappender ) [) not found. [Coverage Status] ( https://coveralls.io/repos/github/rocketmq/rocketmq-logappender/badge.svg?branch=master)](https://coveralls.io/github/rocketmq/rocketmq-logappender?branch=master ) + + +## Introduction +RocketMQ-LogAppender is a logging component implement of log4j,log4j2 and logback.Taking Apache RocketMQ as broker. +All logs loged will be send to the topic you define. + +## Examples + +#### log4j example + +> config detail + +```xml +<appender name="mqAppender1" class="org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender"> + <param name="Tag" value="log1" /> + <param name="Topic" value="TopicTest" /> + <param name="ProducerGroup" value="log4jxml" /> + <param name="NameServerAddress" value="127.0.0.1:9876"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="%d {yyyy-MM-dd HH:mm:ss} -%p %t %c - %m%n" /> + </layout> +</appender> + +<appender name="mqAsyncAppender1" class="org.apache.log4j.AsyncAppender"> + <param name="BufferSize" value="1024" /> + <param name="Blocking" value="false" /> + <appender-ref ref="mqAppender1"></appender-ref> — End diff – why not use single label as above?
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115482303

          — Diff: style/rmq_checkstyle.xml —
          @@ -30,6 +30,12 @@
          <!-- header -->
          <module name="RegexpHeader">
          <property name="header" value="/*\nLicensed to the Apache Software Foundation*"/>
          + <property name="fileExtensions" value="java"/>
          + </module>
          +
          + <module name="RegexpHeader">
          — End diff –

          Old check style is not supported When we add a file such as properties config file.

          Show
          githubbot ASF GitHub Bot added a comment - Github user lindzh commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115482303 — Diff: style/rmq_checkstyle.xml — @@ -30,6 +30,12 @@ <!-- header --> <module name="RegexpHeader"> <property name="header" value="/*\nLicensed to the Apache Software Foundation*"/> + <property name="fileExtensions" value="java"/> + </module> + + <module name="RegexpHeader"> — End diff – Old check style is not supported When we add a file such as properties config file.
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115482388

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j/RocketmqLog4jAppender.java —
          @@ -0,0 +1,193 @@
          +/*
          + * 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.rocketmq.logappender.log4j;
          +
          +import org.apache.rocketmq.common.message.Message;
          +import org.apache.rocketmq.logappender.common.ProducerInstance;
          +import org.apache.log4j.AppenderSkeleton;
          +import org.apache.log4j.helpers.LogLog;
          +import org.apache.log4j.spi.ErrorCode;
          +import org.apache.log4j.spi.LoggingEvent;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +/**
          + * Log4j Appender Component
          + */
          +public class RocketmqLog4jAppender extends AppenderSkeleton {
          +
          + /**
          + * appended message tag define
          — End diff –

          ok

          Show
          githubbot ASF GitHub Bot added a comment - Github user lindzh commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115482388 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j/RocketmqLog4jAppender.java — @@ -0,0 +1,193 @@ +/* + * 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.rocketmq.logappender.log4j; + +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.logappender.common.ProducerInstance; +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.helpers.LogLog; +import org.apache.log4j.spi.ErrorCode; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.rocketmq.client.producer.MQProducer; + +/** + * Log4j Appender Component + */ +public class RocketmqLog4jAppender extends AppenderSkeleton { + + /** + * appended message tag define — End diff – ok
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user lizhanhui commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          Hi, @lindzh could you further justify this PR? Aka, explain why it's reasonable to create a custom appender?

          Show
          githubbot ASF GitHub Bot added a comment - Github user lizhanhui commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 Hi, @lindzh could you further justify this PR? Aka, explain why it's reasonable to create a custom appender?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11433323/badge)](https://coveralls.io/builds/11433323)

          Coverage increased (+0.1%) to 31.109% when pulling *bee9726ba9231b79462536f628d9ff8f88975f4f on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11433323/badge)](https://coveralls.io/builds/11433323 ) Coverage increased (+0.1%) to 31.109% when pulling * bee9726ba9231b79462536f628d9ff8f88975f4f on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11433552/badge)](https://coveralls.io/builds/11433552)

          Coverage increased (+0.1%) to 31.118% when pulling *7fcc19b6b3c40377e5a3e15ba0fbfc0a951d8773 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11433552/badge)](https://coveralls.io/builds/11433552 ) Coverage increased (+0.1%) to 31.118% when pulling * 7fcc19b6b3c40377e5a3e15ba0fbfc0a951d8773 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11449471/badge)](https://coveralls.io/builds/11449471)

          Coverage increased (+0.3%) to 31.304% when pulling *ee05972b1f676cfa87a67fb058905b52bdd913ff on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11449471/badge)](https://coveralls.io/builds/11449471 ) Coverage increased (+0.3%) to 31.304% when pulling * ee05972b1f676cfa87a67fb058905b52bdd913ff on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user lindzh commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          @lizhanhui ,When we print the log to rocketmq provided for big data processing, developers usually need to write their own appender.I think this is very ordinary.Why not provide them as a core component

          Show
          githubbot ASF GitHub Bot added a comment - Github user lindzh commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 @lizhanhui ,When we print the log to rocketmq provided for big data processing, developers usually need to write their own appender.I think this is very ordinary.Why not provide them as a core component
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11454454/badge)](https://coveralls.io/builds/11454454)

          Coverage increased (+0.3%) to 31.295% when pulling *1f9851b6f9b7a4ea25722ef31a7392bccde01cc2 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11454454/badge)](https://coveralls.io/builds/11454454 ) Coverage increased (+0.3%) to 31.295% when pulling * 1f9851b6f9b7a4ea25722ef31a7392bccde01cc2 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11454454/badge)](https://coveralls.io/builds/11454454)

          Coverage increased (+0.3%) to 31.295% when pulling *1f9851b6f9b7a4ea25722ef31a7392bccde01cc2 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11454454/badge)](https://coveralls.io/builds/11454454 ) Coverage increased (+0.3%) to 31.295% when pulling * 1f9851b6f9b7a4ea25722ef31a7392bccde01cc2 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11454454/badge)](https://coveralls.io/builds/11454454)

          Coverage increased (+0.3%) to 31.295% when pulling *1f9851b6f9b7a4ea25722ef31a7392bccde01cc2 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11454454/badge)](https://coveralls.io/builds/11454454 ) Coverage increased (+0.3%) to 31.295% when pulling * 1f9851b6f9b7a4ea25722ef31a7392bccde01cc2 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115888858

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/logback/RocketmqLogbackAppender.java —
          @@ -0,0 +1,184 @@
          +/*
          + * 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.rocketmq.logappender.logback;
          +
          +import ch.qos.logback.classic.net.LoggingEventPreSerializationTransformer;
          +import ch.qos.logback.classic.spi.ILoggingEvent;
          +import ch.qos.logback.core.AppenderBase;
          +import ch.qos.logback.core.Layout;
          +import ch.qos.logback.core.spi.PreSerializationTransformer;
          +import ch.qos.logback.core.status.ErrorStatus;
          +import org.apache.rocketmq.common.message.Message;
          +import org.apache.rocketmq.logappender.common.ProducerInstance;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +/**
          + * Logack Appender Component
          — End diff –

          Logback

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115888858 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/logback/RocketmqLogbackAppender.java — @@ -0,0 +1,184 @@ +/* + * 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.rocketmq.logappender.logback; + +import ch.qos.logback.classic.net.LoggingEventPreSerializationTransformer; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.AppenderBase; +import ch.qos.logback.core.Layout; +import ch.qos.logback.core.spi.PreSerializationTransformer; +import ch.qos.logback.core.status.ErrorStatus; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.logappender.common.ProducerInstance; +import org.apache.rocketmq.client.producer.MQProducer; + +/** + * Logack Appender Component — End diff – Logback
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115886436

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j/RocketmqLog4jAppender.java —
          @@ -0,0 +1,193 @@
          +/*
          + * 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.rocketmq.logappender.log4j;
          +
          +import org.apache.rocketmq.common.message.Message;
          +import org.apache.rocketmq.logappender.common.ProducerInstance;
          +import org.apache.log4j.AppenderSkeleton;
          +import org.apache.log4j.helpers.LogLog;
          +import org.apache.log4j.spi.ErrorCode;
          +import org.apache.log4j.spi.LoggingEvent;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +/**
          + * Log4j Appender Component
          + */
          +public class RocketmqLog4jAppender extends AppenderSkeleton {
          +
          + /**
          + * Appended message tag define
          + */
          + private String tag;
          +
          + /**
          + * Whitch topic to send log messages
          + */
          + private String topic;
          +
          + private boolean locationInfo;
          +
          + /**
          + * Log producer send instance
          + */
          + private MQProducer producer;
          +
          + /**
          + * Lokcetmq nameserver address
          — End diff –

          Lokcetmq?

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115886436 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j/RocketmqLog4jAppender.java — @@ -0,0 +1,193 @@ +/* + * 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.rocketmq.logappender.log4j; + +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.logappender.common.ProducerInstance; +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.helpers.LogLog; +import org.apache.log4j.spi.ErrorCode; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.rocketmq.client.producer.MQProducer; + +/** + * Log4j Appender Component + */ +public class RocketmqLog4jAppender extends AppenderSkeleton { + + /** + * Appended message tag define + */ + private String tag; + + /** + * Whitch topic to send log messages + */ + private String topic; + + private boolean locationInfo; + + /** + * Log producer send instance + */ + private MQProducer producer; + + /** + * Lokcetmq nameserver address — End diff – Lokcetmq?
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115889155

          — Diff: logappender/src/test/java/org/apache/rocketmq/logappender/AbstractTestCase.java —
          @@ -0,0 +1,165 @@
          +/*
          + * 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.rocketmq.logappender;
          +
          +import org.apache.rocketmq.broker.BrokerController;
          +import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
          +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
          +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
          +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
          +import org.apache.rocketmq.client.exception.MQClientException;
          +import org.apache.rocketmq.common.BrokerConfig;
          +import org.apache.rocketmq.common.MQVersion;
          +import org.apache.rocketmq.common.MixAll;
          +import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
          +import org.apache.rocketmq.common.message.MessageExt;
          +import org.apache.rocketmq.common.namesrv.NamesrvConfig;
          +import org.apache.rocketmq.logappender.common.ProducerInstance;
          +import org.apache.rocketmq.namesrv.NamesrvController;
          +import org.apache.rocketmq.remoting.netty.NettyClientConfig;
          +import org.apache.rocketmq.remoting.netty.NettyServerConfig;
          +import org.apache.rocketmq.remoting.protocol.RemotingCommand;
          +import org.apache.rocketmq.store.config.MessageStoreConfig;
          +import org.junit.AfterClass;
          +import org.junit.BeforeClass;
          +
          +import java.util.List;
          +import java.util.Random;
          +import java.util.concurrent.CountDownLatch;
          +import java.util.concurrent.TimeUnit;
          +import java.util.concurrent.atomic.AtomicInteger;
          +
          +/**
          + * Basic test rocketmq broker and name server init
          + */
          +public class AbstractTestCase {
          +
          + private static String nameServer = "localhost:9876";
          +
          + private static NamesrvController namesrvController;
          +
          + private static BrokerController brokerController;
          +
          + private static String topic = "TopicTest";
          +
          + @BeforeClass
          + public static void startRocketmqService() throws Exception {
          +
          + /*
          + Start nameserver
          + */
          + startNamesrv();
          +
          + /*
          + Start broker
          + */
          + startBroker();
          +
          + Thread.sleep(2000);
          — End diff –

          CountDownLatch

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115889155 — Diff: logappender/src/test/java/org/apache/rocketmq/logappender/AbstractTestCase.java — @@ -0,0 +1,165 @@ +/* + * 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.rocketmq.logappender; + +import org.apache.rocketmq.broker.BrokerController; +import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.common.BrokerConfig; +import org.apache.rocketmq.common.MQVersion; +import org.apache.rocketmq.common.MixAll; +import org.apache.rocketmq.common.consumer.ConsumeFromWhere; +import org.apache.rocketmq.common.message.MessageExt; +import org.apache.rocketmq.common.namesrv.NamesrvConfig; +import org.apache.rocketmq.logappender.common.ProducerInstance; +import org.apache.rocketmq.namesrv.NamesrvController; +import org.apache.rocketmq.remoting.netty.NettyClientConfig; +import org.apache.rocketmq.remoting.netty.NettyServerConfig; +import org.apache.rocketmq.remoting.protocol.RemotingCommand; +import org.apache.rocketmq.store.config.MessageStoreConfig; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +import java.util.List; +import java.util.Random; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Basic test rocketmq broker and name server init + */ +public class AbstractTestCase { + + private static String nameServer = "localhost:9876"; + + private static NamesrvController namesrvController; + + private static BrokerController brokerController; + + private static String topic = "TopicTest"; + + @BeforeClass + public static void startRocketmqService() throws Exception { + + /* + Start nameserver + */ + startNamesrv(); + + /* + Start broker + */ + startBroker(); + + Thread.sleep(2000); — End diff – CountDownLatch
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115888889

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/logback/RocketmqLogbackAppender.java —
          @@ -0,0 +1,184 @@
          +/*
          + * 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.rocketmq.logappender.logback;
          +
          +import ch.qos.logback.classic.net.LoggingEventPreSerializationTransformer;
          +import ch.qos.logback.classic.spi.ILoggingEvent;
          +import ch.qos.logback.core.AppenderBase;
          +import ch.qos.logback.core.Layout;
          +import ch.qos.logback.core.spi.PreSerializationTransformer;
          +import ch.qos.logback.core.status.ErrorStatus;
          +import org.apache.rocketmq.common.message.Message;
          +import org.apache.rocketmq.logappender.common.ProducerInstance;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +/**
          + * Logack Appender Component
          + */
          +public class RocketmqLogbackAppender extends AppenderBase<ILoggingEvent> {
          +
          + /**
          + * Appended message tag define
          + */
          + private String tag;
          +
          + /**
          + * Whitch topic to send log messages
          + */
          + private String topic;
          +
          + /**
          + * Rokcetmq nameserver address
          — End diff –

          RocketMQ

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115888889 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/logback/RocketmqLogbackAppender.java — @@ -0,0 +1,184 @@ +/* + * 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.rocketmq.logappender.logback; + +import ch.qos.logback.classic.net.LoggingEventPreSerializationTransformer; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.AppenderBase; +import ch.qos.logback.core.Layout; +import ch.qos.logback.core.spi.PreSerializationTransformer; +import ch.qos.logback.core.status.ErrorStatus; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.logappender.common.ProducerInstance; +import org.apache.rocketmq.client.producer.MQProducer; + +/** + * Logack Appender Component + */ +public class RocketmqLogbackAppender extends AppenderBase<ILoggingEvent> { + + /** + * Appended message tag define + */ + private String tag; + + /** + * Whitch topic to send log messages + */ + private String topic; + + /** + * Rokcetmq nameserver address — End diff – RocketMQ
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115887366

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j2/RocketmqLog4j2Appender.java —
          @@ -0,0 +1,232 @@
          +/*
          + * 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.rocketmq.logappender.log4j2;
          +
          +import org.apache.logging.log4j.core.config.plugins.Plugin;
          +import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
          +import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
          +import org.apache.logging.log4j.core.config.plugins.PluginElement;
          +import org.apache.rocketmq.common.message.Message;
          +import org.apache.rocketmq.logappender.common.ProducerInstance;
          +import org.apache.logging.log4j.core.ErrorHandler;
          +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.plugins.validation.constraints.Required;
          +import org.apache.logging.log4j.core.layout.SerializedLayout;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +import java.io.Serializable;
          +import java.util.concurrent.TimeUnit;
          +
          +/**
          + * Log4j2 Appender Component
          + */
          +@Plugin(
          + name = "Rocketmq",
          — End diff –

          Apache RocketMQ

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115887366 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j2/RocketmqLog4j2Appender.java — @@ -0,0 +1,232 @@ +/* + * 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.rocketmq.logappender.log4j2; + +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; +import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory; +import org.apache.logging.log4j.core.config.plugins.PluginElement; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.logappender.common.ProducerInstance; +import org.apache.logging.log4j.core.ErrorHandler; +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.plugins.validation.constraints.Required; +import org.apache.logging.log4j.core.layout.SerializedLayout; +import org.apache.rocketmq.client.producer.MQProducer; + +import java.io.Serializable; +import java.util.concurrent.TimeUnit; + +/** + * Log4j2 Appender Component + */ +@Plugin( + name = "Rocketmq", — End diff – Apache RocketMQ
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115887404

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j2/RocketmqLog4j2Appender.java —
          @@ -0,0 +1,232 @@
          +/*
          + * 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.rocketmq.logappender.log4j2;
          +
          +import org.apache.logging.log4j.core.config.plugins.Plugin;
          +import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
          +import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
          +import org.apache.logging.log4j.core.config.plugins.PluginElement;
          +import org.apache.rocketmq.common.message.Message;
          +import org.apache.rocketmq.logappender.common.ProducerInstance;
          +import org.apache.logging.log4j.core.ErrorHandler;
          +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.plugins.validation.constraints.Required;
          +import org.apache.logging.log4j.core.layout.SerializedLayout;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +import java.io.Serializable;
          +import java.util.concurrent.TimeUnit;
          +
          +/**
          + * Log4j2 Appender Component
          + */
          +@Plugin(
          + name = "Rocketmq",
          + category = "Core",
          — End diff –

          Core or core ?

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r115887404 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j2/RocketmqLog4j2Appender.java — @@ -0,0 +1,232 @@ +/* + * 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.rocketmq.logappender.log4j2; + +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; +import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory; +import org.apache.logging.log4j.core.config.plugins.PluginElement; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.logappender.common.ProducerInstance; +import org.apache.logging.log4j.core.ErrorHandler; +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.plugins.validation.constraints.Required; +import org.apache.logging.log4j.core.layout.SerializedLayout; +import org.apache.rocketmq.client.producer.MQProducer; + +import java.io.Serializable; +import java.util.concurrent.TimeUnit; + +/** + * Log4j2 Appender Component + */ +@Plugin( + name = "Rocketmq", + category = "Core", — End diff – Core or core ?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user lindzh commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          readme has ben removed

          Show
          githubbot ASF GitHub Bot added a comment - Github user lindzh commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 readme has ben removed
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116140905

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/logback/RocketmqLogbackAppender.java —
          @@ -0,0 +1,184 @@
          +/*
          + * 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.rocketmq.logappender.logback;
          +
          +import ch.qos.logback.classic.net.LoggingEventPreSerializationTransformer;
          +import ch.qos.logback.classic.spi.ILoggingEvent;
          +import ch.qos.logback.core.AppenderBase;
          +import ch.qos.logback.core.Layout;
          +import ch.qos.logback.core.spi.PreSerializationTransformer;
          +import ch.qos.logback.core.status.ErrorStatus;
          +import org.apache.rocketmq.common.message.Message;
          +import org.apache.rocketmq.logappender.common.ProducerInstance;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +/**
          + * Logack Appender Component
          + */
          +public class RocketmqLogbackAppender extends AppenderBase<ILoggingEvent> {
          +
          + /**
          + * Appended message tag define
          + */
          + private String tag;
          +
          + /**
          + * Whitch topic to send log messages
          + */
          + private String topic;
          +
          + /**
          + * Rokcetmq nameserver address
          — End diff –

          fixed

          Show
          githubbot ASF GitHub Bot added a comment - Github user lindzh commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116140905 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/logback/RocketmqLogbackAppender.java — @@ -0,0 +1,184 @@ +/* + * 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.rocketmq.logappender.logback; + +import ch.qos.logback.classic.net.LoggingEventPreSerializationTransformer; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.AppenderBase; +import ch.qos.logback.core.Layout; +import ch.qos.logback.core.spi.PreSerializationTransformer; +import ch.qos.logback.core.status.ErrorStatus; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.logappender.common.ProducerInstance; +import org.apache.rocketmq.client.producer.MQProducer; + +/** + * Logack Appender Component + */ +public class RocketmqLogbackAppender extends AppenderBase<ILoggingEvent> { + + /** + * Appended message tag define + */ + private String tag; + + /** + * Whitch topic to send log messages + */ + private String topic; + + /** + * Rokcetmq nameserver address — End diff – fixed
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116141459

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j2/RocketmqLog4j2Appender.java —
          @@ -0,0 +1,232 @@
          +/*
          + * 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.rocketmq.logappender.log4j2;
          +
          +import org.apache.logging.log4j.core.config.plugins.Plugin;
          +import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
          +import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
          +import org.apache.logging.log4j.core.config.plugins.PluginElement;
          +import org.apache.rocketmq.common.message.Message;
          +import org.apache.rocketmq.logappender.common.ProducerInstance;
          +import org.apache.logging.log4j.core.ErrorHandler;
          +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.plugins.validation.constraints.Required;
          +import org.apache.logging.log4j.core.layout.SerializedLayout;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +import java.io.Serializable;
          +import java.util.concurrent.TimeUnit;
          +
          +/**
          + * Log4j2 Appender Component
          + */
          +@Plugin(
          + name = "Rocketmq",
          + category = "Core",
          — End diff –

          It's Core,write as log4j2 JMSAppender,refer https://github.com/apache/logging-log4j2/blob/dbd2d252a1b4139a9bd9eb213c89f28498db6dcf/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsAppender.java,
          has ben fix to constant.

          Show
          githubbot ASF GitHub Bot added a comment - Github user lindzh commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116141459 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j2/RocketmqLog4j2Appender.java — @@ -0,0 +1,232 @@ +/* + * 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.rocketmq.logappender.log4j2; + +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; +import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory; +import org.apache.logging.log4j.core.config.plugins.PluginElement; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.logappender.common.ProducerInstance; +import org.apache.logging.log4j.core.ErrorHandler; +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.plugins.validation.constraints.Required; +import org.apache.logging.log4j.core.layout.SerializedLayout; +import org.apache.rocketmq.client.producer.MQProducer; + +import java.io.Serializable; +import java.util.concurrent.TimeUnit; + +/** + * Log4j2 Appender Component + */ +@Plugin( + name = "Rocketmq", + category = "Core", — End diff – It's Core,write as log4j2 JMSAppender,refer https://github.com/apache/logging-log4j2/blob/dbd2d252a1b4139a9bd9eb213c89f28498db6dcf/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsAppender.java , has ben fix to constant.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11487751/badge)](https://coveralls.io/builds/11487751)

          Coverage increased (+0.1%) to 31.114% when pulling *e269dc66a1b8ea4fbc699641e0252b23fca7bc81 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11487751/badge)](https://coveralls.io/builds/11487751 ) Coverage increased (+0.1%) to 31.114% when pulling * e269dc66a1b8ea4fbc699641e0252b23fca7bc81 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11487751/badge)](https://coveralls.io/builds/11487751)

          Coverage increased (+0.1%) to 31.114% when pulling *e269dc66a1b8ea4fbc699641e0252b23fca7bc81 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11487751/badge)](https://coveralls.io/builds/11487751 ) Coverage increased (+0.1%) to 31.114% when pulling * e269dc66a1b8ea4fbc699641e0252b23fca7bc81 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11487751/badge)](https://coveralls.io/builds/11487751)

          Coverage increased (+0.1%) to 31.114% when pulling *e269dc66a1b8ea4fbc699641e0252b23fca7bc81 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11487751/badge)](https://coveralls.io/builds/11487751 ) Coverage increased (+0.1%) to 31.114% when pulling * e269dc66a1b8ea4fbc699641e0252b23fca7bc81 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11487766/badge)](https://coveralls.io/builds/11487766)

          Coverage increased (+1.03%) to 32.01% when pulling *e269dc66a1b8ea4fbc699641e0252b23fca7bc81 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11487766/badge)](https://coveralls.io/builds/11487766 ) Coverage increased (+1.03%) to 32.01% when pulling * e269dc66a1b8ea4fbc699641e0252b23fca7bc81 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11487766/badge)](https://coveralls.io/builds/11487766)

          Coverage increased (+1.03%) to 32.01% when pulling *e269dc66a1b8ea4fbc699641e0252b23fca7bc81 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11487766/badge)](https://coveralls.io/builds/11487766 ) Coverage increased (+1.03%) to 32.01% when pulling * e269dc66a1b8ea4fbc699641e0252b23fca7bc81 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11487874/badge)](https://coveralls.io/builds/11487874)

          Coverage increased (+0.4%) to 31.34% when pulling *592a0393d7361ca63fe85dd4fb58fce43809793b on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11487874/badge)](https://coveralls.io/builds/11487874 ) Coverage increased (+0.4%) to 31.34% when pulling * 592a0393d7361ca63fe85dd4fb58fce43809793b on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116381299

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j2/RocketmqLog4j2Appender.java —
          @@ -0,0 +1,233 @@
          +/*
          + * 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.rocketmq.logappender.log4j2;
          +
          +import org.apache.logging.log4j.core.Appender;
          +import org.apache.logging.log4j.core.Filter;
          +import org.apache.logging.log4j.core.ErrorHandler;
          +import org.apache.logging.log4j.core.Layout;
          +import org.apache.logging.log4j.core.LogEvent;
          +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.PluginBuilderAttribute;
          +import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
          +import org.apache.logging.log4j.core.config.plugins.PluginElement;
          +import org.apache.rocketmq.common.message.Message;
          +import org.apache.rocketmq.logappender.common.ProducerInstance;
          +import org.apache.logging.log4j.core.appender.AbstractAppender;
          +import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
          +import org.apache.logging.log4j.core.layout.SerializedLayout;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +import java.io.Serializable;
          +import java.util.concurrent.TimeUnit;
          +
          +/**
          + * Log4j2 Appender Component
          + */
          +@Plugin(name = "RocketMQ",
          + category = Node.CATEGORY,
          + elementType = Appender.ELEMENT_TYPE,
          + printObject = true)
          +public class RocketmqLog4j2Appender extends AbstractAppender {
          +
          + /**
          + * RocketMQ nameserver address
          + */
          + private String nameServerAddress;
          +
          + /**
          + * Log producer group
          + */
          + private String producerGroup;
          +
          + /**
          + * Log producer send instance
          + */
          + private MQProducer producer;
          +
          + /**
          + * Appended message tag define
          + */
          + private String tag;
          +
          + /**
          + * Whitch topic to send log messages
          + */
          + private String topic;
          +
          +
          + protected RocketmqLog4j2Appender(String name, Filter filter, Layout<? extends Serializable> layout,
          + boolean ignoreExceptions, String nameServerAddress, String producerGroup,
          + String topic, String tag) {
          + super(name, filter, layout, ignoreExceptions);
          + this.producer = producer;
          + this.topic = topic;
          + this.tag = tag;
          + this.nameServerAddress = nameServerAddress;
          + this.producerGroup = producerGroup;
          + try

          { + this.producer = ProducerInstance.getInstance(this.nameServerAddress, this.producerGroup); + }

          catch (Exception e) {
          + ErrorHandler handler = this.getHandler();
          + if (handler != null)

          { + handler.error("Starting RocketmqLog4j2Appender [" + this.getName() + + "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage()); + }

          + }
          + }
          +
          + /**
          + * Info,error,warn,callback method implementation
          + *
          + * @param event
          + */
          + public void append(LogEvent event) {
          + if (null == producer)

          { + return; + }

          +
          + try

          { + byte[] bytes = this.getLayout().toByteArray(event); + Message msg = new Message(topic, tag, bytes); + msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOG4J2_APPENDER); + + //Send message and do not wait for the ack from the message broker. + producer.sendOneway(msg); + }

          catch (Exception e) {
          + ErrorHandler handler = this.getHandler();
          + if (handler != null) {
          + handler.error("Could not send message in RocketmqLog4j2Appender [" + this.getName() + "].", e);
          — End diff –

          May be we want to know which log message isn't send to server?

          Show
          githubbot ASF GitHub Bot added a comment - Github user zhouxinyu commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116381299 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/log4j2/RocketmqLog4j2Appender.java — @@ -0,0 +1,233 @@ +/* + * 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.rocketmq.logappender.log4j2; + +import org.apache.logging.log4j.core.Appender; +import org.apache.logging.log4j.core.Filter; +import org.apache.logging.log4j.core.ErrorHandler; +import org.apache.logging.log4j.core.Layout; +import org.apache.logging.log4j.core.LogEvent; +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.PluginBuilderAttribute; +import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory; +import org.apache.logging.log4j.core.config.plugins.PluginElement; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.logappender.common.ProducerInstance; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required; +import org.apache.logging.log4j.core.layout.SerializedLayout; +import org.apache.rocketmq.client.producer.MQProducer; + +import java.io.Serializable; +import java.util.concurrent.TimeUnit; + +/** + * Log4j2 Appender Component + */ +@Plugin(name = "RocketMQ", + category = Node.CATEGORY, + elementType = Appender.ELEMENT_TYPE, + printObject = true) +public class RocketmqLog4j2Appender extends AbstractAppender { + + /** + * RocketMQ nameserver address + */ + private String nameServerAddress; + + /** + * Log producer group + */ + private String producerGroup; + + /** + * Log producer send instance + */ + private MQProducer producer; + + /** + * Appended message tag define + */ + private String tag; + + /** + * Whitch topic to send log messages + */ + private String topic; + + + protected RocketmqLog4j2Appender(String name, Filter filter, Layout<? extends Serializable> layout, + boolean ignoreExceptions, String nameServerAddress, String producerGroup, + String topic, String tag) { + super(name, filter, layout, ignoreExceptions); + this.producer = producer; + this.topic = topic; + this.tag = tag; + this.nameServerAddress = nameServerAddress; + this.producerGroup = producerGroup; + try { + this.producer = ProducerInstance.getInstance(this.nameServerAddress, this.producerGroup); + } catch (Exception e) { + ErrorHandler handler = this.getHandler(); + if (handler != null) { + handler.error("Starting RocketmqLog4j2Appender [" + this.getName() + + "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage()); + } + } + } + + /** + * Info,error,warn,callback method implementation + * + * @param event + */ + public void append(LogEvent event) { + if (null == producer) { + return; + } + + try { + byte[] bytes = this.getLayout().toByteArray(event); + Message msg = new Message(topic, tag, bytes); + msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOG4J2_APPENDER); + + //Send message and do not wait for the ack from the message broker. + producer.sendOneway(msg); + } catch (Exception e) { + ErrorHandler handler = this.getHandler(); + if (handler != null) { + handler.error("Could not send message in RocketmqLog4j2Appender [" + this.getName() + "] .", e); — End diff – May be we want to know which log message isn't send to server?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user zhouxinyu commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          BTW, do we use the batch feature in this appender?

          Show
          githubbot ASF GitHub Bot added a comment - Github user zhouxinyu commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 BTW, do we use the batch feature in this appender?
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116382010

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java —
          @@ -0,0 +1,96 @@
          +/*
          + * 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.rocketmq.logappender.common;
          +
          +import org.apache.rocketmq.client.exception.MQClientException;
          +import org.apache.rocketmq.client.producer.DefaultMQProducer;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +import java.util.Map;
          +import java.util.Set;
          +import java.util.concurrent.ConcurrentHashMap;
          +
          +/**
          + * Common Producer component
          + */
          +public class ProducerInstance {
          +
          + public static final String APPENDER_TYPE = "APPENDER_TYPE";
          +
          + public static final String LOG4J_APPENDER = "LOG4J_APPENDER";
          +
          + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER";
          +
          + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER";
          +
          + public static final String DEFAULT_GROUP = "rocketmq_appender";
          +
          + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>();
          +
          + private static String genKey(String nameServerAddress, String group)

          { + return nameServerAddress + "_" + group; + }

          +
          +
          + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException {
          + if (group == null)

          { + group = DEFAULT_GROUP; + }

          +
          + String genKey = genKey(nameServerAddress, group);
          + MQProducer p = producerMap.get(genKey);
          + if (p != null)

          { + return p; + }

          +
          + DefaultMQProducer defaultMQProducer = new DefaultMQProducer(group);
          + defaultMQProducer.setNamesrvAddr(nameServerAddress);
          + MQProducer beforeProducer = null;
          + //cas put producer
          + synchronized (producerMap) {
          — End diff –

          It seems that there is no need to use `synchronized `?

          Show
          githubbot ASF GitHub Bot added a comment - Github user zhouxinyu commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116382010 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java — @@ -0,0 +1,96 @@ +/* + * 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.rocketmq.logappender.common; + +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.client.producer.MQProducer; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Common Producer component + */ +public class ProducerInstance { + + public static final String APPENDER_TYPE = "APPENDER_TYPE"; + + public static final String LOG4J_APPENDER = "LOG4J_APPENDER"; + + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER"; + + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER"; + + public static final String DEFAULT_GROUP = "rocketmq_appender"; + + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>(); + + private static String genKey(String nameServerAddress, String group) { + return nameServerAddress + "_" + group; + } + + + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException { + if (group == null) { + group = DEFAULT_GROUP; + } + + String genKey = genKey(nameServerAddress, group); + MQProducer p = producerMap.get(genKey); + if (p != null) { + return p; + } + + DefaultMQProducer defaultMQProducer = new DefaultMQProducer(group); + defaultMQProducer.setNamesrvAddr(nameServerAddress); + MQProducer beforeProducer = null; + //cas put producer + synchronized (producerMap) { — End diff – It seems that there is no need to use `synchronized `?
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116382074

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java —
          @@ -0,0 +1,96 @@
          +/*
          + * 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.rocketmq.logappender.common;
          +
          +import org.apache.rocketmq.client.exception.MQClientException;
          +import org.apache.rocketmq.client.producer.DefaultMQProducer;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +import java.util.Map;
          +import java.util.Set;
          +import java.util.concurrent.ConcurrentHashMap;
          +
          +/**
          + * Common Producer component
          + */
          +public class ProducerInstance {
          +
          + public static final String APPENDER_TYPE = "APPENDER_TYPE";
          +
          + public static final String LOG4J_APPENDER = "LOG4J_APPENDER";
          +
          + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER";
          +
          + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER";
          +
          + public static final String DEFAULT_GROUP = "rocketmq_appender";
          +
          + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>();
          +
          + private static String genKey(String nameServerAddress, String group)

          { + return nameServerAddress + "_" + group; + }

          +
          +
          + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException {
          + if (group == null)

          { + group = DEFAULT_GROUP; + }

          +
          + String genKey = genKey(nameServerAddress, group);
          + MQProducer p = producerMap.get(genKey);
          + if (p != null) {
          + return p;
          — End diff –

          Maybe `p` isn't a started producer instance momently?

          Show
          githubbot ASF GitHub Bot added a comment - Github user zhouxinyu commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116382074 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java — @@ -0,0 +1,96 @@ +/* + * 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.rocketmq.logappender.common; + +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.client.producer.MQProducer; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Common Producer component + */ +public class ProducerInstance { + + public static final String APPENDER_TYPE = "APPENDER_TYPE"; + + public static final String LOG4J_APPENDER = "LOG4J_APPENDER"; + + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER"; + + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER"; + + public static final String DEFAULT_GROUP = "rocketmq_appender"; + + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>(); + + private static String genKey(String nameServerAddress, String group) { + return nameServerAddress + "_" + group; + } + + + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException { + if (group == null) { + group = DEFAULT_GROUP; + } + + String genKey = genKey(nameServerAddress, group); + MQProducer p = producerMap.get(genKey); + if (p != null) { + return p; — End diff – Maybe `p` isn't a started producer instance momently?
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116382123

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java —
          @@ -0,0 +1,96 @@
          +/*
          + * 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.rocketmq.logappender.common;
          +
          +import org.apache.rocketmq.client.exception.MQClientException;
          +import org.apache.rocketmq.client.producer.DefaultMQProducer;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +import java.util.Map;
          +import java.util.Set;
          +import java.util.concurrent.ConcurrentHashMap;
          +
          +/**
          + * Common Producer component
          + */
          +public class ProducerInstance {
          +
          + public static final String APPENDER_TYPE = "APPENDER_TYPE";
          +
          + public static final String LOG4J_APPENDER = "LOG4J_APPENDER";
          +
          + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER";
          +
          + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER";
          +
          + public static final String DEFAULT_GROUP = "rocketmq_appender";
          +
          + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>();
          +
          + private static String genKey(String nameServerAddress, String group)

          { + return nameServerAddress + "_" + group; + }

          +
          +
          + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException {
          + if (group == null)

          { + group = DEFAULT_GROUP; + }
          +
          + String genKey = genKey(nameServerAddress, group);
          + MQProducer p = producerMap.get(genKey);
          + if (p != null) { + return p; + }
          +
          + DefaultMQProducer defaultMQProducer = new DefaultMQProducer(group);
          + defaultMQProducer.setNamesrvAddr(nameServerAddress);
          + MQProducer beforeProducer = null;
          + //cas put producer
          + synchronized (producerMap) { + beforeProducer = producerMap.putIfAbsent(genKey, defaultMQProducer); + }
          + if (beforeProducer != null) { + return beforeProducer; + }
          + defaultMQProducer.start();
          + return defaultMQProducer;
          + }
          +
          +
          + public static void removeAndClose(String nameServerAddress, String group) {
          + if (group == null) { + group = DEFAULT_GROUP; + }

          + String genKey = genKey(nameServerAddress, group);
          + MQProducer producer = producerMap.get(genKey);
          — End diff –

          ```
          MQProducer producer = producerMap.get(genKey);
          producerMap.remove(genKey);
          ```
          can be replaced by:

          ```
          MQProducer producer = producerMap.remove(genKey);
          ```

          Show
          githubbot ASF GitHub Bot added a comment - Github user zhouxinyu commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116382123 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java — @@ -0,0 +1,96 @@ +/* + * 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.rocketmq.logappender.common; + +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.client.producer.MQProducer; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Common Producer component + */ +public class ProducerInstance { + + public static final String APPENDER_TYPE = "APPENDER_TYPE"; + + public static final String LOG4J_APPENDER = "LOG4J_APPENDER"; + + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER"; + + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER"; + + public static final String DEFAULT_GROUP = "rocketmq_appender"; + + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>(); + + private static String genKey(String nameServerAddress, String group) { + return nameServerAddress + "_" + group; + } + + + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException { + if (group == null) { + group = DEFAULT_GROUP; + } + + String genKey = genKey(nameServerAddress, group); + MQProducer p = producerMap.get(genKey); + if (p != null) { + return p; + } + + DefaultMQProducer defaultMQProducer = new DefaultMQProducer(group); + defaultMQProducer.setNamesrvAddr(nameServerAddress); + MQProducer beforeProducer = null; + //cas put producer + synchronized (producerMap) { + beforeProducer = producerMap.putIfAbsent(genKey, defaultMQProducer); + } + if (beforeProducer != null) { + return beforeProducer; + } + defaultMQProducer.start(); + return defaultMQProducer; + } + + + public static void removeAndClose(String nameServerAddress, String group) { + if (group == null) { + group = DEFAULT_GROUP; + } + String genKey = genKey(nameServerAddress, group); + MQProducer producer = producerMap.get(genKey); — End diff – ``` MQProducer producer = producerMap.get(genKey); producerMap.remove(genKey); ``` can be replaced by: ``` MQProducer producer = producerMap.remove(genKey); ```
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116638805

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java —
          @@ -0,0 +1,96 @@
          +/*
          + * 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.rocketmq.logappender.common;
          +
          +import org.apache.rocketmq.client.exception.MQClientException;
          +import org.apache.rocketmq.client.producer.DefaultMQProducer;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +import java.util.Map;
          +import java.util.Set;
          +import java.util.concurrent.ConcurrentHashMap;
          +
          +/**
          + * Common Producer component
          + */
          +public class ProducerInstance {
          +
          + public static final String APPENDER_TYPE = "APPENDER_TYPE";
          +
          + public static final String LOG4J_APPENDER = "LOG4J_APPENDER";
          +
          + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER";
          +
          + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER";
          +
          + public static final String DEFAULT_GROUP = "rocketmq_appender";
          +
          + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>();
          +
          + private static String genKey(String nameServerAddress, String group)

          { + return nameServerAddress + "_" + group; + }

          +
          +
          + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException {
          + if (group == null)

          { + group = DEFAULT_GROUP; + }
          +
          + String genKey = genKey(nameServerAddress, group);
          + MQProducer p = producerMap.get(genKey);
          + if (p != null) { + return p; + }
          +
          + DefaultMQProducer defaultMQProducer = new DefaultMQProducer(group);
          + defaultMQProducer.setNamesrvAddr(nameServerAddress);
          + MQProducer beforeProducer = null;
          + //cas put producer
          + synchronized (producerMap) { + beforeProducer = producerMap.putIfAbsent(genKey, defaultMQProducer); + }
          + if (beforeProducer != null) { + return beforeProducer; + }
          + defaultMQProducer.start();
          + return defaultMQProducer;
          + }
          +
          +
          + public static void removeAndClose(String nameServerAddress, String group) {
          + if (group == null) { + group = DEFAULT_GROUP; + }

          + String genKey = genKey(nameServerAddress, group);
          + MQProducer producer = producerMap.get(genKey);
          — End diff –

          Yes,makes it more simple.

          Show
          githubbot ASF GitHub Bot added a comment - Github user lindzh commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116638805 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java — @@ -0,0 +1,96 @@ +/* + * 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.rocketmq.logappender.common; + +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.client.producer.MQProducer; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Common Producer component + */ +public class ProducerInstance { + + public static final String APPENDER_TYPE = "APPENDER_TYPE"; + + public static final String LOG4J_APPENDER = "LOG4J_APPENDER"; + + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER"; + + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER"; + + public static final String DEFAULT_GROUP = "rocketmq_appender"; + + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>(); + + private static String genKey(String nameServerAddress, String group) { + return nameServerAddress + "_" + group; + } + + + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException { + if (group == null) { + group = DEFAULT_GROUP; + } + + String genKey = genKey(nameServerAddress, group); + MQProducer p = producerMap.get(genKey); + if (p != null) { + return p; + } + + DefaultMQProducer defaultMQProducer = new DefaultMQProducer(group); + defaultMQProducer.setNamesrvAddr(nameServerAddress); + MQProducer beforeProducer = null; + //cas put producer + synchronized (producerMap) { + beforeProducer = producerMap.putIfAbsent(genKey, defaultMQProducer); + } + if (beforeProducer != null) { + return beforeProducer; + } + defaultMQProducer.start(); + return defaultMQProducer; + } + + + public static void removeAndClose(String nameServerAddress, String group) { + if (group == null) { + group = DEFAULT_GROUP; + } + String genKey = genKey(nameServerAddress, group); + MQProducer producer = producerMap.get(genKey); — End diff – Yes,makes it more simple.
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116641020

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java —
          @@ -0,0 +1,96 @@
          +/*
          + * 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.rocketmq.logappender.common;
          +
          +import org.apache.rocketmq.client.exception.MQClientException;
          +import org.apache.rocketmq.client.producer.DefaultMQProducer;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +import java.util.Map;
          +import java.util.Set;
          +import java.util.concurrent.ConcurrentHashMap;
          +
          +/**
          + * Common Producer component
          + */
          +public class ProducerInstance {
          +
          + public static final String APPENDER_TYPE = "APPENDER_TYPE";
          +
          + public static final String LOG4J_APPENDER = "LOG4J_APPENDER";
          +
          + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER";
          +
          + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER";
          +
          + public static final String DEFAULT_GROUP = "rocketmq_appender";
          +
          + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>();
          +
          + private static String genKey(String nameServerAddress, String group)

          { + return nameServerAddress + "_" + group; + }

          +
          +
          + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException {
          + if (group == null)

          { + group = DEFAULT_GROUP; + }

          +
          + String genKey = genKey(nameServerAddress, group);
          + MQProducer p = producerMap.get(genKey);
          + if (p != null)

          { + return p; + }

          +
          + DefaultMQProducer defaultMQProducer = new DefaultMQProducer(group);
          + defaultMQProducer.setNamesrvAddr(nameServerAddress);
          + MQProducer beforeProducer = null;
          + //cas put producer
          + synchronized (producerMap) {
          — End diff –

          As log initlizer is serializable,there is no need to user synchronized

          Show
          githubbot ASF GitHub Bot added a comment - Github user lindzh commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116641020 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java — @@ -0,0 +1,96 @@ +/* + * 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.rocketmq.logappender.common; + +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.client.producer.MQProducer; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Common Producer component + */ +public class ProducerInstance { + + public static final String APPENDER_TYPE = "APPENDER_TYPE"; + + public static final String LOG4J_APPENDER = "LOG4J_APPENDER"; + + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER"; + + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER"; + + public static final String DEFAULT_GROUP = "rocketmq_appender"; + + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>(); + + private static String genKey(String nameServerAddress, String group) { + return nameServerAddress + "_" + group; + } + + + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException { + if (group == null) { + group = DEFAULT_GROUP; + } + + String genKey = genKey(nameServerAddress, group); + MQProducer p = producerMap.get(genKey); + if (p != null) { + return p; + } + + DefaultMQProducer defaultMQProducer = new DefaultMQProducer(group); + defaultMQProducer.setNamesrvAddr(nameServerAddress); + MQProducer beforeProducer = null; + //cas put producer + synchronized (producerMap) { — End diff – As log initlizer is serializable,there is no need to user synchronized
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116641839

          — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java —
          @@ -0,0 +1,96 @@
          +/*
          + * 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.rocketmq.logappender.common;
          +
          +import org.apache.rocketmq.client.exception.MQClientException;
          +import org.apache.rocketmq.client.producer.DefaultMQProducer;
          +import org.apache.rocketmq.client.producer.MQProducer;
          +
          +import java.util.Map;
          +import java.util.Set;
          +import java.util.concurrent.ConcurrentHashMap;
          +
          +/**
          + * Common Producer component
          + */
          +public class ProducerInstance {
          +
          + public static final String APPENDER_TYPE = "APPENDER_TYPE";
          +
          + public static final String LOG4J_APPENDER = "LOG4J_APPENDER";
          +
          + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER";
          +
          + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER";
          +
          + public static final String DEFAULT_GROUP = "rocketmq_appender";
          +
          + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>();
          +
          + private static String genKey(String nameServerAddress, String group)

          { + return nameServerAddress + "_" + group; + }

          +
          +
          + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException {
          + if (group == null)

          { + group = DEFAULT_GROUP; + }

          +
          + String genKey = genKey(nameServerAddress, group);
          + MQProducer p = producerMap.get(genKey);
          + if (p != null) {
          + return p;
          — End diff –

          As log initlizer is serializable,if it has ben started before,it must be started.

          Show
          githubbot ASF GitHub Bot added a comment - Github user lindzh commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq/pull/101#discussion_r116641839 — Diff: logappender/src/main/java/org/apache/rocketmq/logappender/common/ProducerInstance.java — @@ -0,0 +1,96 @@ +/* + * 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.rocketmq.logappender.common; + +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.client.producer.MQProducer; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Common Producer component + */ +public class ProducerInstance { + + public static final String APPENDER_TYPE = "APPENDER_TYPE"; + + public static final String LOG4J_APPENDER = "LOG4J_APPENDER"; + + public static final String LOG4J2_APPENDER = "LOG4J2_APPENDER"; + + public static final String LOGBACK_APPENDER = "LOGBACK_APPENDER"; + + public static final String DEFAULT_GROUP = "rocketmq_appender"; + + private static ConcurrentHashMap<String, MQProducer> producerMap = new ConcurrentHashMap<String, MQProducer>(); + + private static String genKey(String nameServerAddress, String group) { + return nameServerAddress + "_" + group; + } + + + public static MQProducer getInstance(String nameServerAddress, String group) throws MQClientException { + if (group == null) { + group = DEFAULT_GROUP; + } + + String genKey = genKey(nameServerAddress, group); + MQProducer p = producerMap.get(genKey); + if (p != null) { + return p; — End diff – As log initlizer is serializable,if it has ben started before,it must be started.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11538511/badge)](https://coveralls.io/builds/11538511)

          Coverage increased (+0.3%) to 31.268% when pulling *fde2f7803500f4b4154c01c32dbfc5230e208805 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11538511/badge)](https://coveralls.io/builds/11538511 ) Coverage increased (+0.3%) to 31.268% when pulling * fde2f7803500f4b4154c01c32dbfc5230e208805 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11538511/badge)](https://coveralls.io/builds/11538511)

          Coverage increased (+0.3%) to 31.268% when pulling *fde2f7803500f4b4154c01c32dbfc5230e208805 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11538511/badge)](https://coveralls.io/builds/11538511 ) Coverage increased (+0.3%) to 31.268% when pulling * fde2f7803500f4b4154c01c32dbfc5230e208805 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user coveralls commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          [![Coverage Status](https://coveralls.io/builds/11538511/badge)](https://coveralls.io/builds/11538511)

          Coverage increased (+0.3%) to 31.268% when pulling *fde2f7803500f4b4154c01c32dbfc5230e208805 on lindzh:log_appender* into *fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master*.

          Show
          githubbot ASF GitHub Bot added a comment - Github user coveralls commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 [! [Coverage Status] ( https://coveralls.io/builds/11538511/badge)](https://coveralls.io/builds/11538511 ) Coverage increased (+0.3%) to 31.268% when pulling * fde2f7803500f4b4154c01c32dbfc5230e208805 on lindzh:log_appender * into * fa85abcdf6ee46e56403ddf86828a38683103fd0 on apache:master *.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 37fbb7be8ae2a932f14006a2c08e3247143f75ea in incubator-rocketmq's branch refs/heads/develop from lindzh
          [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=37fbb7b ]

          ROCKETMQ-194 log appender support closes apache/incubator-rocketmq#101

          Show
          jira-bot ASF subversion and git services added a comment - Commit 37fbb7be8ae2a932f14006a2c08e3247143f75ea in incubator-rocketmq's branch refs/heads/develop from lindzh [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=37fbb7b ] ROCKETMQ-194 log appender support closes apache/incubator-rocketmq#101
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user dongeforever commented on the issue:

          https://github.com/apache/incubator-rocketmq/pull/101

          @lindzh this PR is merged. You may close this PR now

          Show
          githubbot ASF GitHub Bot added a comment - Github user dongeforever commented on the issue: https://github.com/apache/incubator-rocketmq/pull/101 @lindzh this PR is merged. You may close this PR now
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user lindzh closed the pull request at:

          https://github.com/apache/incubator-rocketmq/pull/101

          Show
          githubbot ASF GitHub Bot added a comment - Github user lindzh closed the pull request at: https://github.com/apache/incubator-rocketmq/pull/101
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user lindzh opened a pull request:

          https://github.com/apache/incubator-rocketmq-site/pull/18

          ROCKETMQ-194Add logappender example

          add logappender example

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

          $ git pull https://github.com/lindzh/incubator-rocketmq-site logappender

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

          https://github.com/apache/incubator-rocketmq-site/pull/18.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 #18


          commit 833ade9091eca6467d498c457ee67310f27a18ee
          Author: 鲁般 <dezhi.ldz@alibaba-inc.com>
          Date: 2017-06-08T13:19:26Z

          add logappender example


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user lindzh opened a pull request: https://github.com/apache/incubator-rocketmq-site/pull/18 ROCKETMQ-194 Add logappender example add logappender example You can merge this pull request into a Git repository by running: $ git pull https://github.com/lindzh/incubator-rocketmq-site logappender Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-rocketmq-site/pull/18.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 #18 commit 833ade9091eca6467d498c457ee67310f27a18ee Author: 鲁般 <dezhi.ldz@alibaba-inc.com> Date: 2017-06-08T13:19:26Z add logappender example
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq-site/pull/18#discussion_r120898077

          — Diff: _docs/20-logappender-example.md —
          @@ -0,0 +1,80 @@
          +---
          +title: "Logappender Example"
          +permalink: /docs/logappender-example/
          +excerpt: "How to use logappender in RocketMQ."
          +modified: 2017-06-08T21:01:43-04:00
          +---
          +
          +

          {% include toc %}

          +
          +When we use rocketmq as a part of big data processing or other cases,bussiness also need to put log data to rocketmq.Rocketmq logappender provides log4j appender,logback appender and log4j2 appender for bussiness to use,below is some example.
          — End diff –

          1. rocketmq vs. Rocketmq, which one
          2. RocketMQ's logappender

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq-site/pull/18#discussion_r120898077 — Diff: _docs/20-logappender-example.md — @@ -0,0 +1,80 @@ +--- +title: "Logappender Example" +permalink: /docs/logappender-example/ +excerpt: "How to use logappender in RocketMQ." +modified: 2017-06-08T21:01:43-04:00 +--- + + {% include toc %} + +When we use rocketmq as a part of big data processing or other cases,bussiness also need to put log data to rocketmq.Rocketmq logappender provides log4j appender,logback appender and log4j2 appender for bussiness to use,below is some example. — End diff – 1. rocketmq vs. Rocketmq, which one 2. RocketMQ's logappender
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq-site/pull/18#discussion_r120898962

          — Diff: _docs/20-logappender-example.md —
          @@ -0,0 +1,80 @@
          +---
          +title: "Logappender Example"
          +permalink: /docs/logappender-example/
          +excerpt: "How to use logappender in RocketMQ."
          +modified: 2017-06-08T21:01:43-04:00
          +---
          +
          +

          {% include toc %}

          +
          +When we use rocketmq as a part of big data processing or other cases,bussiness also need to put log data to rocketmq.Rocketmq logappender provides log4j appender,logback appender and log4j2 appender for bussiness to use,below is some example.
          +
          +#### log4j
          +
          +When using log4j properties config file,config as below.
          +
          +```
          +log4j.appender.mq=org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender
          +log4j.appender.mq.Tag=yourTag
          +log4j.appender.mq.Topic=yourLogTopic
          +log4j.appender.mq.ProducerGroup=yourLogGroup
          +log4j.appender.mq.NameServerAddress=yourRocketmqNameserverAddress
          +log4j.appender.mq.layout=org.apache.log4j.PatternLayout
          +log4j.appender.mq.layout.ConversionPattern=%d

          {yyyy-MM-dd HH:mm:ss}

          %-4r [%t] (%F:%L) %-5p - %m%n
          +```
          +
          +When using log4j xml config file,config it as this and also add a async appender:
          +
          +```
          +<appender name="mqAppender1" class="org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender">
          + <param name="Tag" value="yourTag" />
          — End diff –

          capitalize the first letter in name?

          Show
          githubbot ASF GitHub Bot added a comment - Github user vongosling commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq-site/pull/18#discussion_r120898962 — Diff: _docs/20-logappender-example.md — @@ -0,0 +1,80 @@ +--- +title: "Logappender Example" +permalink: /docs/logappender-example/ +excerpt: "How to use logappender in RocketMQ." +modified: 2017-06-08T21:01:43-04:00 +--- + + {% include toc %} + +When we use rocketmq as a part of big data processing or other cases,bussiness also need to put log data to rocketmq.Rocketmq logappender provides log4j appender,logback appender and log4j2 appender for bussiness to use,below is some example. + +#### log4j + +When using log4j properties config file,config as below. + +``` +log4j.appender.mq=org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender +log4j.appender.mq.Tag=yourTag +log4j.appender.mq.Topic=yourLogTopic +log4j.appender.mq.ProducerGroup=yourLogGroup +log4j.appender.mq.NameServerAddress=yourRocketmqNameserverAddress +log4j.appender.mq.layout=org.apache.log4j.PatternLayout +log4j.appender.mq.layout.ConversionPattern=%d {yyyy-MM-dd HH:mm:ss} %-4r [%t] (%F:%L) %-5p - %m%n +``` + +When using log4j xml config file,config it as this and also add a async appender: + +``` +<appender name="mqAppender1" class="org.apache.rocketmq.logappender.log4j.RocketmqLog4jAppender"> + <param name="Tag" value="yourTag" /> — End diff – capitalize the first letter in name?
          Hide
          githubbot ASF GitHub Bot added a comment -

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

          https://github.com/apache/incubator-rocketmq-site/pull/18#discussion_r121620804

          — Diff: _docs/20-logappender-example.md —
          @@ -0,0 +1,80 @@
          +---
          +title: "Logappender Example"
          +permalink: /docs/logappender-example/
          +excerpt: "How to use logappender in RocketMQ."
          +modified: 2017-06-08T21:01:43-04:00
          +---
          +
          +

          {% include toc %}

          +
          +When we use rocketmq as a part of big data processing or other cases,bussiness also need to put log data to rocketmq.Rocketmq logappender provides log4j appender,logback appender and log4j2 appender for bussiness to use,below is some example.
          — End diff –

          "Rocketmq logappender provides log4j appender,logback appender and log4j2 appender for bussiness to use,below is some example."--> RocketMQ log appender provides log4j, logback and log4j2 appenders for business developers. The following are some examples.

          Show
          githubbot ASF GitHub Bot added a comment - Github user lizhanhui commented on a diff in the pull request: https://github.com/apache/incubator-rocketmq-site/pull/18#discussion_r121620804 — Diff: _docs/20-logappender-example.md — @@ -0,0 +1,80 @@ +--- +title: "Logappender Example" +permalink: /docs/logappender-example/ +excerpt: "How to use logappender in RocketMQ." +modified: 2017-06-08T21:01:43-04:00 +--- + + {% include toc %} + +When we use rocketmq as a part of big data processing or other cases,bussiness also need to put log data to rocketmq.Rocketmq logappender provides log4j appender,logback appender and log4j2 appender for bussiness to use,below is some example. — End diff – "Rocketmq logappender provides log4j appender,logback appender and log4j2 appender for bussiness to use,below is some example."--> RocketMQ log appender provides log4j, logback and log4j2 appenders for business developers. The following are some examples.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/incubator-rocketmq-site/pull/18

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/incubator-rocketmq-site/pull/18

            People

            • Assignee:
              vongosling vongosling
              Reporter:
              lindzh lindzh
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 72h
                72h
                Remaining:
                Remaining Estimate - 72h
                72h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development