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

Skip to content

Conversation

@OrezzerO
Copy link
Contributor

@OrezzerO OrezzerO commented Nov 9, 2022

Please answer these questions before submitting a pull request

  • Why submit this pull request?

  • Bugfix

  • 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

Comment on lines +91 to +95
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.4.4</version>
</dependency>
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.

@tzssangglass
Copy link
Member

@tzssangglass tzssangglass merged commit e18da5c into apache:main Nov 14, 2022
@tzssangglass
Copy link
Member

@OrezzerO merged, many thanks.

@OrezzerO OrezzerO mentioned this pull request Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants