logrotate works fine with Bitcoin Core, you just need to send SIGHUP to it after rotating so that it starts writing a new log file.
Just reading through the problem you were having last year, the issue is that logrotate is a one shot command, not a persistent daemon (not sure how I missed this the first time). When it runs, it checks whether the log file matches it's criteria for rotating and keeping old logs, and if it does, it will rotate the log files and do whatever. However, it does not sit there watching the specified files to see if they match, rather it requires something external to kick it off. This is usually done with a systemd timer which specifies how frequently it should be run. I would guess that it was running once per day, whereas you probably want it to run more frequently, like every hour. You'll need to find the logrotate.timer systemd unit file and modify it to start logrotate at the frequency that works with how quickly your log files grow.
You can find where systemd unit files are located by using
systemctl status, e.g.
sudo systemctl status logrotate.timer
I have mine setup to rotate the log files every hour if they are bigger than 5 MB, and to save the old log files to my NAS. Here's what my whole config looks like:
/etc/logrotate.d/bitcoin/home/ava/.bitcoin/debug.log /home/ava/.bitcoin/testnet3/debug.log /home/ava/.bitcoin/signet/debug.log {
rotate -1
size 5M
dateformat %Y-%m-%d-%H_%M
dateext
olddir oldlogs
postrotate
/home/ava/.bitcoin/finish-logrotate.sh $@
endscript
}
/home/ava/.bitcoin/finish-logrotate.sh is a script that sends the SIGHUB signal and moves the rotated log file to the NAS:
#! /usr/bin/bash
LOGS_DIR=$(dirname ${2})
BASE_DIR=$(dirname ${LOGS_DIR})
PID_FILE="${BASE_DIR}/bitcoind.pid"
NET=$(basename ${BASE_DIR})
if [[ "$NET" == .bitcoin ]]; then
NET="mainnet"
fi
if [[ -f "${PID_FILE}" ]]; then
kill -s SIGHUP $(cat ${PID_FILE})
fi
for f in ${LOGS_DIR}/*; do
gzip -q ${f}
done
if [[ $(mountpoint "/mnt/data") ]]; then
NAS_LOGS_DIR="/mnt/data/bitcoin/oldlogs/${NET}/"
mv $LOGS_DIR/* $NAS_LOGS_DIR
fi
/usr/lib/systemd/system/logrotate.timer is logrotate's systemd timer unit file:
[Unit]
Description=Hourly rotation of log files
Documentation=man:logrotate(8) man:logrotate.conf(5)
[Timer]
OnCalendar=hourly
AccuracySec=1h
Persistent=true
[Install]
WantedBy=timers.target