You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "wklken (via GitHub)" <gi...@apache.org> on 2023/06/25 15:13:52 UTC

[GitHub] [apisix] wklken opened a new issue, #9722: feat: plugin log-rotate should use log.warn if the file not exists

wklken opened a new issue, #9722:
URL: https://github.com/apache/apisix/issues/9722

   ### Description
   
   We have some instances on standby (with no requests or access logs), but we keep receiving alert messages like
   
   ```
   [lua] log-rotate.lua:162: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2023-06-24_00-00-00__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory
   ```
   
   https://github.com/apache/apisix/blob/fc5ae822d26451cd9241425f14fd4ca22de8af02/apisix/plugins/log-rotate.lua#L147-L152
   
   can we use `log.warn` instead `log.error` if the err is `No such file or directory`?
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] wklken commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "wklken (via GitHub)" <gi...@apache.org>.
wklken commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1619380112

   Do you mean that `log-rotate` is mainly designed for the default Nginx access.log, and that while `log-rotate` and `file-logger` can work together, but they are not very compatible?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] monkeyDluffy6017 commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1614522420

   1. Could you describe in full the steps you took? like in what order do you start APISIX and delete the access log?
   2. What's your APISIX version?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] monkeyDluffy6017 commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1613561328

   There is no problem with this error log, as long as the access log exists, even if there is no request, it does not affect the rotate of the access log. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] wklken commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "wklken (via GitHub)" <gi...@apache.org>.
wklken commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1619286201

   Use both `file-logger` and `log-rotate`, we need to get APISIX variables.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] monkeyDluffy6017 commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1639319731

   I'will close this issue, feel free to reopen it


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] monkeyDluffy6017 commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1619390891

   Yes, the `log-rotate` plugin is only designed for the default Nginx access.log and error.log


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] monkeyDluffy6017 closed issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 closed issue #9722: feat: plugin log-rotate should use log.warn if the file not exists
URL: https://github.com/apache/apisix/issues/9722


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] wklken commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "wklken (via GitHub)" <gi...@apache.org>.
wklken commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1613947278

   It's not the rotation of the access log that matters, but rather the error log.
   
   We collect the error log (level=error) and use an alert manager to send messages. This means that we should always add a filter rule to ignore `No such file or directory` errors after deployment.
   
   Is the only way to add the access log file back to add a cron job to make a request?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] moonming commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "moonming (via GitHub)" <gi...@apache.org>.
moonming commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1607138571

   We should judge whether this file exists, and then move this file.
   Welcome PR to fix @wklken 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] Revolyssup commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1606577234

   Do these standby instances share the same configuration as the APISIX instance in use? If not, then can you disable log-rotate plugin on these standby instances ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] wklken commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "wklken (via GitHub)" <gi...@apache.org>.
wklken commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1615388693

   > 1. Could you describe in full the steps you took? like in what order do you start APISIX and delete the access log?
   > 2. What's your APISIX version?
   
   
   I make a demo to reproduce the error
   
   ```Dockerfile
   ARG APISIX_VERSION="3.2.1"
   FROM apache/apisix:$APISIX_VERSION-centos
   
   WORKDIR /usr/local/apisix
   
   # no link to stdout/stderr, use file log collector
   RUN rm -rf /usr/local/apisix/logs/* && chmod 777 /usr/local/apisix/logs
   
   # no default nginx access log, use the plugin file-logger.path to define the log path
   RUN sed -i 's/enable_access_log: true/enable_access_log: false/g' /usr/local/apisix/conf/config-default.yaml
   ```
   
   build
   
   ```bash
   docker build -t apache/apisix:development .
   ```
   
   run as standalone mode
   
   ```bash
   docker run --rm --name apache-apisix \
     -p 9080:9080 \
     -e APISIX_STAND_ALONE=true \
     apache/apisix:development
   ```
   
   update the apisix.yaml (based on apisix-docker docs)
   
   ```bash
   docker exec -i apache-apisix sh -c 'cat > /usr/local/apisix/conf/apisix.yaml <<_EOC_
   deployment:
     role: data_plane
     role_data_plane:
       config_provider: yaml
   
   plugins:
     - name: file-logger
     - name: log-rotate
   
   routes:
     -
       id: httpbin
       uri: /*
       upstream:
         nodes:
           "httpbin.org": 1
         type: roundrobin
       plugin_config_id: 1
   
   plugin_configs:
     -
       id: 1
       plugins:
         response-rewrite:
           body: "Hello APISIX\n"
       desc: "response-rewrite"
   
   #END
   _EOC_'
   ```
   
   then, enter the container, update the `plugin_attr` in `config.yaml` (another terminal windown)
   
   ```bash
   docker exec -it apache-apisix /bin/bash
   vim conf/config.yaml
   ```
   
   ```yaml file:config.yaml
   plugin_attr:
     log-rotate:
       interval: 1 
       max_kept: 7 
       max_size: 1073741824
       enable_compression: false 
     file-logger:
       path: logs/access.log
   ```
   
   then, reload
   
   ```bash
   apisix reload
   tail -f log/error.log
   ```
   
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] Sn0rt commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "Sn0rt (via GitHub)" <gi...@apache.org>.
Sn0rt commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1624648282

   @Sn0rt should I update a doc tell the user the `log-rotate` work scope


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] wklken commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "wklken (via GitHub)" <gi...@apache.org>.
wklken commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1614372387

   - change the `plugin_attr.log-rotate.interval` to `1` and start the apisix. 
   - no request
   - the error 
   
   ```
   2023/06/30 09:09:48 [error] 40#40: *112 [lua] log-rotate.lua:162: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2023-06-30_09-09-48__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory, context: ngx.timer
   2023/06/30 09:09:49 [error] 40#40: *142 [lua] log-rotate.lua:162: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2023-06-30_09-09-49__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory, context: ngx.timer
   2023/06/30 09:09:50 [error] 40#40: *167 [lua] log-rotate.lua:162: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2023-06-30_09-09-50__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory, context: ngx.timer
   2023/06/30 09:09:51 [error] 40#40: *192 [lua] log-rotate.lua:162: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2023-06-30_09-09-51__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory, context: ngx.timer
   2023/06/30 09:09:52 [error] 40#40: *219 [lua] log-rotate.lua:162: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2023-06-30_09-09-52__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory, context: ngx.timer
   2023/06/30 09:09:53 [error] 40#40: *243 [lua] log-rotate.lua:162: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2023-06-30_09-09-53__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory, context: ngx.timer
   2023/06/30 09:09:54 [error] 40#40: *268 [lua] log-rotate.lua:162: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2023-06-30_09-09-54__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory, context: ngx.timer
   2023/06/30 09:09:55 [error] 40#40: *295 [lua] log-rotate.lua:162: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2023-06-30_09-09-55__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory, context: ngx.timer
   2023/06/30 09:09:56 [error] 40#40: *320 [lua] log-rotate.lua:162: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2023-06-30_09-09-56__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory, context: ngx.timer
   2023/06/30 09:09:57 [error] 40#40: *345 [lua] log-rotate.lua:162: rename_file(): move file from /usr/local/apisix/logs/access.log to /usr/local/apisix/logs//2023-06-30_09-09-57__access.log res:nil msg:/usr/local/apisix/logs/access.log: No such file or directory, context: ngx.timer
   ```
   
   ----
   
   and i think even when the first request coming, an error log which level is `error` show is not ok, while `No such file or directory` is not the user need to know, it would be better to change that log level to `warn`.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] monkeyDluffy6017 commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1613970031

   **This error log will not be generated as long as the access log exists, even if there is no request.**
   So i don't know what is your problem, you could make a simple test in your local environment


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] monkeyDluffy6017 commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1619358536

   The `log-rotate` plugin cannot be applied to the `file-logger` plugin, which APISIX variable do you want to use?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] monkeyDluffy6017 commented on issue #9722: feat: plugin log-rotate should use log.warn if the file not exists

Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on issue #9722:
URL: https://github.com/apache/apisix/issues/9722#issuecomment-1618901752

   Why do you use the `file-logger` to replace the original access log?
   The `file-logger` plugin doesn't support log rotate now.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org