You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/08/21 15:46:29 UTC

[GitHub] [apisix] qihaiyan commented on a diff in pull request #7749: feat(log-rorate): log-rotate plugin support max_size

qihaiyan commented on code in PR #7749:
URL: https://github.com/apache/apisix/pull/7749#discussion_r950865175


##########
apisix/plugins/log-rotate.lua:
##########
@@ -251,7 +263,18 @@ local function rotate()
     if now_time < rotate_time then
         -- did not reach the rotate time
         core.log.info("rotate time: ", rotate_time, " now time: ", now_time)
-        return
+
+        local log_file = assert(io_open(default_logs[DEFAULT_ACCESS_LOG_FILENAME].file, "r"))
+        local access_log_file_size = file_size(log_file)
+        log_file:close()
+
+        log_file = assert(io_open(default_logs[DEFAULT_ERROR_LOG_FILENAME].file, "r"))
+        local error_log_file_size = file_size(log_file)
+        log_file:close()
+
+        if max_size <= 0 or access_log_file_size < max_size and error_log_file_size < max_size then

Review Comment:
   > It seems the error log file will be rotated when the access log is too big?
   
   yes



-- 
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