apisix icon indicating copy to clipboard operation
apisix copied to clipboard

bug: log-rotate plugin should not rotate the access log when the enable_access_log setting is set to false

Open flearc opened this issue 1 year ago • 2 comments

Current Behavior

The log-rotate plugin rotates the access log regardless of the enable_access_log setting.

Expected Behavior

The log-rotate plugin should skip rotating the access log if enable_access_log is set to false.

Error Logs

2024/05/31 09:41:48 [error] 57#57: *428 [lua] log-rotate.lua:150: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2024-05-31_09-41-48__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory, context: ngx.timer

Steps to Reproduce

  1. Add the Configuration to config.yaml
nginx_config:
  http:
    enable_access_log: false

plugins:
  - log-rotate

plugin_attr:
  log-rotate:
    interval: 1
  1. Mount config.yaml and run APISIX via the docker image
  2. Check the error log

Environment

  • APISIX version (run apisix version): 3.9.0

flearc avatar May 31 '24 09:05 flearc

Verified with the latest code and it does have this problem.

Baoyuantop avatar May 16 '25 07:05 Baoyuantop

Verified with the latest code and it does have this problem.

I will reopen the PR.

flearc avatar May 16 '25 10:05 flearc