<@U0A71G31CDV> how to keep only last 3 day logs in...
# questions-and-troubleshooting
z
@Rocky how to keep only last 3 day logs in fe/cn/be logs?
r
To keep only the last 3 days of logs for StarRocks components, you need to adjust different configuration parameters for the FE and the BE/CN, as they use different logging frameworks (Log4j for FE and GLOG for BE/CN). 1. FE Configuration (
fe.conf
)
The Frontend (FE) uses a time-based deletion policy for various log types. Add or modify the following parameters: * System Logs (
fe.log
):
sys_log_delete_age = 3d
* Audit Logs (
fe.audit.log
):
audit_log_delete_age = 3d
* Big Query Logs (
fe.big_query.log
):
big_query_log_delete_age = 3d
* Internal Logs:
internal_log_delete_age = 3d
* Profile Logs:
profile_log_delete_age = 3d
(Default is
1d
) 2. BE/CN Configuration (
be.conf
/
cn.conf
)
The Backend (BE) and Compute Node (CN) do not have a direct
delete_age
parameter for system logs. Instead, they manage log retention based on the number of files (
sys_log_roll_num
) and the rotation mode (
sys_log_roll_mode
). To approximate a 3-day retention policy: * System Logs (
<http://be.INFO|be.INFO>
,
be.WARN
, etc.):
Set the rotation to daily and keep 3 files.
Copy code
properties
    sys_log_roll_mode = TIME-DAY
    sys_log_roll_num = 3
_Note:
sys_log_roll_mode
defaults to
SIZE-MB-1024
. By changing it to
TIME-DAY
, a new log file is created every day. Setting
sys_log_roll_num
to 3 will then keep the last 3 daily files._ * Load Error Logs: These logs are stored in the storage directory and are managed by hours.
Copy code
properties
    load_error_log_reserve_hours = 72
Important Notes: 1. Static Parameters: Most of these parameters (especially those in
fe.conf
) are static. You must restart the FE/BE/CN process after modifying the configuration files for the changes to take effect. 2.
.out
Files:
The
.out
files (e.g.,
fe.out
,
be.out
) capture standard output and do not support automatic rotation or deletion through these internal settings. These should be managed using external tools like
logrotate
if they grow too large. 3. Storage: Ensure that the user running StarRocks has sufficient permissions to delete files in the log directories. Referencesadministration/management/FE_configuration.mdadministration/management/BE_configuration.md