Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ target/
!**/src/main/**/target/
!**/src/test/**/target/
release/
logs/

### IntelliJ IDEA ###
.idea
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Comment on lines +91 to +95
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disruptor is a "High Performance Inter-Thread Messaging Library" . Log4j2 uses this lib to implement async logging.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

<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:

<appender-ref ref="CONSOLE"/>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions runner-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
Expand Down
59 changes: 59 additions & 0 deletions runner-starter/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -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>