apache / apisix-go-plugin-runner

Go Plugin Runner for APISIX
https://apisix.apache.org/
Apache License 2.0
167 stars 69 forks source link

help request: How to customize the log file path in apisix-go-plugin-runner #118

Open ZChengjin opened 1 year ago

ZChengjin commented 1 year ago

Description

As the documentation says I modified the LogOutput of runner.RunnerConfig{} by modifying LogFilePath, but no matter what path I modify LogFilePath to, the log of go-plugin will be printed in apisix_log/error.log in the end.So I want to know How can I customize the log file path in apisix-go-plugin-runner.Thanks

Environment

APISIX version (run apisix version):3.0.0 Operating system (run uname -a):Linux eee3e01b5631 4.19.76-linuxkit https://github.com/apache/apisix/pull/1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 GNU/Linux OpenResty / Nginx version (run openresty -V or nginx -V):nginx version: openresty/1.21.4.1;built by gcc 10.2.1 20210110 (Debian 10.2.1-6);built with OpenSSL 1.1.1n 15 Mar 2022 etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info): APISIX Dashboard version, if relevant:apache/apisix-dashboard:2.13-alpine Plugin runner version, for issues related to plugin runners:apisix-go-plugin-runner(master) LuaRocks version, for installation issues (run luarocks --version):

Hazel6869 commented 1 year ago

@ZChengjin Hi, can you give me your code? I will check for you.

Hazel6869 commented 1 year ago

@ZChengjin are you reload the code?

ZChengjin commented 1 year ago

of course

ZChengjin commented 1 year ago

@ZChengjin Hi, can you give me your code? I will check for you.

const (
    Dev  RunMode = iota // Development
    Prod                // Product
    Prof                // Profile

    ProfileFilePath = "./logs/profile."
    LogFilePath     = "../apisix_log/test.log"  //i just modified this
)

I just modified the LogFilePath in apisix-go-plugin-runner/cmd/go-runner/main.go

soulbird commented 1 year ago

Are you sure this path exists? Are there any failed to open log... related logs in the apisix log? Can you see the go-runner log if you don't make any changes?

jobop commented 1 year ago

i have the same problem

soulbird commented 1 year ago

go-runner is started in dev mode by default, and the log will be output in stdout. When go-runner is hosted in apisix, the log will be output in error.log. You can use go-runner run -m prod to change the run mode of go-runner so that you can see individual log files. In apisix, you can use the following configuration:

ext-plugin:
   cmd: ["/path-to-your/go-runner/apisix-go-runner", "run", "-m", "prod"]

We will supplement the documentation on this.