Skip to content

bug: Logging using pkg/log does not work #149

@Blinkuu

Description

@Blinkuu

Issue description

I followed the blog post describing how to implement an external plugin using Go SDK. I've successfully managed to connect APISIX with my plugin process. On top of that, I can see logs being printed to stdout:

2023-11-13T15:37:38.412Z        INFO    plugin/plugin.go:73     register plugin fault-injection
2023-11-13T15:37:38.412Z        INFO    plugin/plugin.go:73     register plugin limit-req
2023-11-13T15:37:38.412Z        INFO    plugin/plugin.go:73     register plugin response-rewrite
2023-11-13T15:37:38.412Z        INFO    plugin/plugin.go:73     register plugin say
2023-11-13T15:37:38.412Z        WARN    server/server.go:192    conf cache ttl is 1h12m0s
2023-11-13T15:37:38.412Z        WARN    server/server.go:200    listening to /tmp/runner.sock
2023-11-13T15:37:52.667Z        INFO    server/server.go:115    Client connected (unix)
2023-11-13T15:37:52.667Z        INFO    server/server.go:115    Client connected (unix)
2023-11-13T15:37:52.667Z        INFO    server/server.go:131    receive rpc type: 1 data length: 136
2023-11-13T15:37:52.667Z        INFO    plugin/conf.go:98       prepare conf for plugin say
2023-11-13T15:37:52.668Z        INFO    server/server.go:131    receive rpc type: 2 data length: 652
2023-11-13T15:37:52.668Z        INFO    plugin/plugin.go:120    run plugin say
2023-11-13T15:37:53.290Z        INFO    server/server.go:115    Client connected (unix)
2023-11-13T15:37:53.290Z        INFO    server/server.go:115    Client connected (unix)
2023-11-13T15:37:53.290Z        INFO    server/server.go:131    receive rpc type: 2 data length: 652
2023-11-13T15:37:53.291Z        INFO    plugin/plugin.go:120    run plugin say

I tried adding my own logs by importing the github.com/apache/apisix-go-plugin-runner/pkg/log package and using it inside my RequestFilter(...) implementation:

func (p *Say) RequestFilter(conf interface{}, w http.ResponseWriter, r pkgHTTP.Request) {
	log.Infof("Hello from Go plugin!") // This doesn't get printed to `stdout`, no matter the level.

	body := conf.(SayConf).Body
	if len(body) == 0 {
		return
	}
}

However, I actually don't see any logs I created being printed.

Environment

  • APISIX Go Plugin Runner's version: v0.5.0
  • APISIX version: 3.6.0
  • Go version: 1.21.3
  • OS (cmd: uname -a): Docker container based on golang:1.21-bullseye image

Minimal test code / Steps to reproduce the issue

N/A

What's the actual result? (including assertion message & call stack if applicable)

I see both INFO and WARN logs from places like server/server.go and plugin/plugin.go.

What's the expected result?

I expect to see my own logs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions