qihaiyan commented on code in PR #7749:
URL: https://github.com/apache/apisix/pull/7749#discussion_r951293942
##########
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:
done
##########
docs/en/latest/plugins/log-rotate.md:
##########
@@ -39,6 +39,7 @@ You can configure how often the logs are rotated and how many
logs to keep. When
|--------------------|---------|----------|---------|------------------------------------------------------------------------------------------------|
| interval | integer | True | 60 * 60 | Time in seconds
specifying how often to rotate the logs. |
| max_kept | integer | True | 24 * 7 | Maximum number of
historical logs to keep. If this number is exceeded, older logs are deleted. |
+| max_size | integer | False | -1 | Max size(Bytes) of log
files to be rotated, size check would be skipped with a value less than 0. |
Review Comment:
done
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]