You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/11/09 06:59:33 UTC

[GitHub] [apisix-java-plugin-runner] OrezzerO opened a new pull request, #214: feat: add log4j2 configuration

OrezzerO opened a new pull request, #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214

   
   Please answer these questions before submitting a pull request
   
   - Why submit this pull request?
   - [ ] Bugfix
   - [x] New feature provided
   - [ ] Improve performance
   
   - Related issues
   
   ### New feature or improvement
   - Describe the details and related test reports.
    Add log4j configuration. The logs will be at `${user.dir}/logs/java-runner-common-default.log` and `${user.dir}/logs/java-runner-common-error.log`.  In apisix env, `${user.dir}` generally equals `/usr/local/apisix/`.
   
   - Source branch
   
   - Related commits and pull requests
   
   - Target branch
   
   Related issue: #22 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] OrezzerO commented on a diff in pull request #214: feat: add log4j2 configuration

Posted by GitBox <gi...@apache.org>.
OrezzerO commented on code in PR #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214#discussion_r1021200938


##########
pom.xml:
##########
@@ -88,6 +88,11 @@
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
+            <dependency>
+                <groupId>com.lmax</groupId>
+                <artifactId>disruptor</artifactId>
+                <version>3.4.4</version>
+            </dependency>

Review Comment:
   Already set `<asyncRoot>`, so there is no need to set system property "log4j2.contextSelector" to any value.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] tzssangglass merged pull request #214: feat: add log4j2 configuration

Posted by GitBox <gi...@apache.org>.
tzssangglass merged PR #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] tzssangglass commented on a diff in pull request #214: feat: add log4j2 configuration

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214#discussion_r1021116652


##########
pom.xml:
##########
@@ -88,6 +88,11 @@
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
+            <dependency>
+                <groupId>com.lmax</groupId>
+                <artifactId>disruptor</artifactId>
+                <version>3.4.4</version>
+            </dependency>

Review Comment:
   do we need to set the system property `log4j2.contextSelector` to `org.apache.logging.log4j.core.async.AsyncLoggerContextSelector` ref: https://logging.apache.org/log4j/2.x/manual/async.html



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] tzssangglass commented on pull request #214: feat: add log4j2 configuration

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on PR #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214#issuecomment-1313687860

   @OrezzerO merged, many thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] tzssangglass commented on a diff in pull request #214: feat: add log4j2 configuration

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214#discussion_r1019106785


##########
pom.xml:
##########
@@ -88,6 +88,11 @@
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
+            <dependency>
+                <groupId>com.lmax</groupId>
+                <artifactId>disruptor</artifactId>
+                <version>3.4.4</version>
+            </dependency>

Review Comment:
   With this lib added, will the java runner logs be output in APISIX?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] OrezzerO commented on a diff in pull request #214: feat: add log4j2 configuration

Posted by GitBox <gi...@apache.org>.
OrezzerO commented on code in PR #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214#discussion_r1021204140


##########
runner-starter/src/main/resources/log4j2.xml:
##########
@@ -0,0 +1,59 @@
+<?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.
+  ~
+  -->
+
+<configuration status="OFF">
+
+    <Properties>
+        <Property name="LOG_LEVEL">debug</Property>
+        <Property name="USER_DIR">${sys:user.dir}</Property>
+        <Property name="FILE_ENCODING">${sys:file.encoding}</Property>
+    </Properties>
+
+    <Appenders>
+        <RollingFile name="ERROR-APPENDER" fileName="${USER_DIR}/logs/java-runner-common-error.log" append="true"
+                     filePattern="${USER_DIR}/logs/java-runner-common-error.log.%d{yyyy-MM-dd}">
+            <!-- only print error log -->
+            <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
+            <PatternLayout charset="${FILE_ENCODING}">
+                <pattern>%d %-5p %-32t - %m%n %throwable</pattern>
+            </PatternLayout>
+            <Policies>
+                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
+            </Policies>
+        </RollingFile>
+
+        <RollingFile name="ROOT-APPENDER" fileName="${USER_DIR}/logs/java-runner-common-default.log" append="true"
+                     filePattern="${USER_DIR}/logs/java-runner-common-default.log.%d{yyyy-MM-dd}">
+            <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
+            <PatternLayout charset="${FILE_ENCODING}">
+                <pattern>%d %-5p %-32t - %m%n %throwable</pattern>
+            </PatternLayout>
+            <Policies>
+                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
+            </Policies>
+        </RollingFile>
+    </Appenders>
+
+    <Loggers>
+        <AsyncRoot level="${LOG_LEVEL}">
+            <appender-ref ref="ROOT-APPENDER"/>
+            <appender-ref ref="ERROR-APPENDER"/>
+        </AsyncRoot>
+    </Loggers>
+</configuration>

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] OrezzerO commented on a diff in pull request #214: feat: add log4j2 configuration

Posted by GitBox <gi...@apache.org>.
OrezzerO commented on code in PR #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214#discussion_r1018794609


##########
pom.xml:
##########
@@ -88,6 +88,11 @@
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
+            <dependency>
+                <groupId>com.lmax</groupId>
+                <artifactId>disruptor</artifactId>
+                <version>3.4.4</version>
+            </dependency>

Review Comment:
    [disruptor](https://lmax-exchange.github.io/disruptor/) is a "High Performance Inter-Thread Messaging Library" . Log4j2 uses this lib to implement async logging.
    



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] tzssangglass commented on pull request #214: feat: add log4j2 configuration

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on PR #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214#issuecomment-1313161353

   we need to add log path to https://github.com/apache/apisix-java-plugin-runner/blob/main/.gitignore#L25


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] OrezzerO commented on a diff in pull request #214: feat: add log4j2 configuration

Posted by GitBox <gi...@apache.org>.
OrezzerO commented on code in PR #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214#discussion_r1019796882


##########
pom.xml:
##########
@@ -88,6 +88,11 @@
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
+            <dependency>
+                <groupId>com.lmax</groupId>
+                <artifactId>disruptor</artifactId>
+                <version>3.4.4</version>
+            </dependency>

Review Comment:
   It is `log4j2.xml`  decides whether runner's logs be output in  APISIX. Now runners log will not be send to APISIX. If users want to send logs to apisix, they need add following code in `log4j2.xml`:
   
   
   Add a appender:
   ```xml
   <Console name="CONSOLE" target="SYSTEM_OUT" follow="true">
       <PatternLayout charset="${FILE_ENCODING}">
           <pattern>%d %-5p %-32t - %m%n %throwable</pattern>
       </PatternLayout>
   </Console>
   ```
   
   Add appender above to loggers:
   ```xml
   <appender-ref ref="CONSOLE"/>
   ```
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] tzssangglass commented on a diff in pull request #214: feat: add log4j2 configuration

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214#discussion_r1018703960


##########
pom.xml:
##########
@@ -88,6 +88,11 @@
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
+            <dependency>
+                <groupId>com.lmax</groupId>
+                <artifactId>disruptor</artifactId>
+                <version>3.4.4</version>
+            </dependency>

Review Comment:
   Is this a complete framework or just a logging component?
   What is the link to its repository?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] tzssangglass commented on a diff in pull request #214: feat: add log4j2 configuration

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #214:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/214#discussion_r1021116250


##########
runner-starter/src/main/resources/log4j2.xml:
##########
@@ -0,0 +1,59 @@
+<?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.
+  ~
+  -->
+
+<configuration status="OFF">
+
+    <Properties>
+        <Property name="LOG_LEVEL">debug</Property>
+        <Property name="USER_DIR">${sys:user.dir}</Property>
+        <Property name="FILE_ENCODING">${sys:file.encoding}</Property>
+    </Properties>
+
+    <Appenders>
+        <RollingFile name="ERROR-APPENDER" fileName="${USER_DIR}/logs/java-runner-common-error.log" append="true"
+                     filePattern="${USER_DIR}/logs/java-runner-common-error.log.%d{yyyy-MM-dd}">
+            <!-- only print error log -->
+            <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
+            <PatternLayout charset="${FILE_ENCODING}">
+                <pattern>%d %-5p %-32t - %m%n %throwable</pattern>
+            </PatternLayout>
+            <Policies>
+                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
+            </Policies>
+        </RollingFile>
+
+        <RollingFile name="ROOT-APPENDER" fileName="${USER_DIR}/logs/java-runner-common-default.log" append="true"
+                     filePattern="${USER_DIR}/logs/java-runner-common-default.log.%d{yyyy-MM-dd}">
+            <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
+            <PatternLayout charset="${FILE_ENCODING}">
+                <pattern>%d %-5p %-32t - %m%n %throwable</pattern>
+            </PatternLayout>
+            <Policies>
+                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
+            </Policies>
+        </RollingFile>
+    </Appenders>
+
+    <Loggers>
+        <AsyncRoot level="${LOG_LEVEL}">
+            <appender-ref ref="ROOT-APPENDER"/>
+            <appender-ref ref="ERROR-APPENDER"/>
+        </AsyncRoot>
+    </Loggers>
+</configuration>

Review Comment:
   add a black line at the end of file



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org