處理Debian上JS日志過大的問題,可參考以下方法:
logrotate工具自動壓縮、刪除舊日志。安裝后配置/etc/logrotate.d/下的配置文件,設置輪轉周期(如每天)、保留天數、壓縮等參數,例如:/var/log/js/*.log {
daily
rotate 7
compress
missingok
notifempty
create 640 root adm
}
執行sudo logrotate -f /etc/logrotate.conf測試配置。winston、log4js)的級別為warn或error,減少非必要日志輸出。cron任務定期刪除過期日志,或使用rm命令手動清理,如sudo rm /var/log/js.log.*。