Hi
@iansen and
@radugt
the symptoms look the same, but the two cases aren't: iansen (Plesk 18.0.43, Ubuntu 20.04) has no confirmed cause yet, while radugt (Plesk 18.0.81, Debian 13) found his. So here are two separate paths. Replace anything in angle brackets with your own values. Run all commands as root.
The key point: the anonymization happens through a postrotate step in each domain's logrotate file (/usr/local/psa/etc/logrotate.d/<DOMAIN>). If that step is missing there, nothing ever gets anonymized, even with the global option switched on.
PART A - for iansen (Plesk 18.0.43, Ubuntu 20.04)
Status: cause NOT confirmed. Approach = diagnose, then decide.
Step A1 - Check the current state (read-only, changes nothing):
Code:
plesk db -Ne "select * from misc where param like '%anonymize%'"
ls -l /opt/psa/admin/sbin/anonymize_ip
grep -L anonymize_ip /usr/local/psa/etc/logrotate.d/*
- Option isn't "true": turn it on with
Code:
plesk bin settings -s logrotate_anonymize_ips=true
- anonymize_ip is missing (ls says: No such file): repair the panel, then run A1 again
Code:
plesk repair installation
- The grep lists files: go to A2 (radugt's cause applies).
- The grep lists nothing: the files are fine, go to A3.
Step A2 - Have the logrotate files rewritten (backup first):
Code:
cp -a /usr/local/psa/etc/logrotate.d /root/logrotate.d.bak-$(date +%F)
for d in $(plesk db -Ne "select domains.name from domains left join dom_param on domains.id=dom_param.dom_id left join log_rotation on dom_param.val=log_rotation.id where domains.htype='vrt_hst' and dom_param.param='logrotation_id' and log_rotation.turned_on='true'"); do plesk bin domain --update "$d" -log-rotate true; done
grep -L anonymize_ip /usr/local/psa/etc/logrotate.d/*
If some files still don't have anonymize_ip: for each domain, go to Websites & Domains > <DOMAIN> > Logs > Log Rotation and just click OK without changing anything (that's what rewrote the files for radugt). Then test as in B3.
Step A3 - The files are correct but nothing gets anonymized anyway:
Code:
logrotate -d -v /usr/local/psa/etc/logrotate.d/<DOMAIN>
tail -n 100 /var/log/plesk/panel.log
grep -rl logrot /etc/cron.d /etc/cron.daily /etc/systemd/system 2>/dev/null
systemctl list-timers | grep -i -E "logrot|plesk"
The dry run (-d) doesn't rotate anything, but it shows errors in the script and whether the postrotate step would actually run. The rest tells you whether rotation runs via a Plesk cron job or timer at all, and whether the panel log has any errors about anonymize_ip.
Step A4 - If A1 to A3 turn up nothing: contact Plesk support (as IgorG recommended) and send them the output of A1 and A3 plus the contents of /usr/local/psa/etc/logrotate.d/<DOMAIN>.
PART B - for radugt's case (Plesk 18.0.81, Debian 13)
Status: cause and fix confirmed by radugt.
Step B1 - Find out which domains are missing the step (read-only):
Code:
grep -L anonymize_ip /usr/local/psa/etc/logrotate.d/*
Step B2 - Get the files rewritten. The confirmed way: for each domain, go to Websites & Domains > <DOMAIN> > Logs > Log Rotation and click OK, changing nothing. Switching the option on server-wide does NOT rewrite existing files, so you have to do each domain individually. CLI alternative (from the thread, not confirmed in this case):
Code:
cp -a /usr/local/psa/etc/logrotate.d /root/logrotate.d.bak-$(date +%F)
for d in $(plesk db -Ne "select domains.name from domains left join dom_param on domains.id=dom_param.dom_id left join log_rotation on dom_param.val=log_rotation.id where domains.htype='vrt_hst' and dom_param.param='logrotation_id' and log_rotation.turned_on='true'"); do plesk bin domain --update "$d" -log-rotate true; done
Step B3 - Check and do a test rotation:
Code:
grep -A2 postrotate /usr/local/psa/etc/logrotate.d/<DOMAIN>
logrotate -f /usr/local/psa/etc/logrotate.d/<DOMAIN>
ls -l /var/www/vhosts/system/<DOMAIN>/logs/
zcat -f /var/www/vhosts/system/<DOMAIN>/logs/<ROTATED_LOGFILE> | head -n 5
What you should see: the line "anonymize_ip --find-rotated-logs" in the postrotate block, and in the freshly rotated file the IPs end in 0. Logs rotated before anonymization was working stay as they are until rotation deletes them.
Step B4 - System logs (Apache, nginx, mail, fail2ban). WARNING: without -K, this command deleted all rotated system logs for radugt (it printed "Failed to remove ...: Success. Continue." even though it really did delete them). Suspected cause: --rot-count defaults to -1. So check your disk space and make a backup first, then run it with -K:
Code:
du -sh /var/log
cp -a /var/log /root/var-log.bak-$(date +%F)
plesk sbin logrot_mng --help
plesk sbin logrot_mng --system-logs --anonymize-ip=true -K
That -K prevents the deletion is just an assumption based on the logrot_mng help text and hasn't been tested, which is why the backup is there.
Note on hardlinks: every domain log exists twice, under /var/www/vhosts/system/<DOMAIN>/logs and /var/www/vhosts/<DOMAIN>/logs. The content is only really gone once the file is deleted in both places.
Regards
Tessa