• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Create daily access logs

HielkeJ

New Pleskian
Hello,

I want to save the access logs of our websites on an external server. If I do this now with the default setup, the gets overwritten every day. The desired file name format whould be: websitedomain-tld-access-2014-10-24.log

How can I tell Plesk to do this and how can I make sure the statistics keep working?

On our other servers we use rotatelogs for this.

Thanks!
 
You might edit the domain-specific logrotate - definitions, located at "/usr/local/psa/etc/logrotate.d" . An example, based on your specifications would be:

Code:
/var/www/vhosts/system/YOUR-SPECIFIC-DOMAIN.COM/logs/access_log {
    daily
    missingok
    rotate 30
    notifempty
    dateext
    nocompress
    nomail
    dateformat _YOUR-SPECIFIC-DOMAIN.COM-%Y-%m-%d.log
}
/var/www/vhosts/system/YOUR-SPECIFIC-DOMAIN.COM/logs/proxy_access_log {
    daily
    missingok
    rotate 30
    notifempty
    dateext
    nocompress
    nomail
    dateformat _YOUR-SPECIFIC-DOMAIN.COM-%Y-%m-%d.log
}
As you can see, the definition would add a date-extension to the rotated log, so the rotated logs would look this way: access-log_YOUR-SPECIFIC-DOMAIN.COM-2014-10-24.log or proxy_access-log_YOUR-SPECIFIC-DOMAIN.COM-2014-10-24.log.


Be aware, that the files in "/usr/local/psa/etc/logrotate.d" might get overritten by Plesk in case of updates/upgrades/patches, or if you change settings for a subscription plan or for domain. This mentioned on the top of all files.
 
Thank you for this solution. Is there an option to make sure that the lines are added after a change / update?

If that is not possible, I will create a script and start that with the event handler.
 
Sure, HielkeJ,

just make an exact copy of the log - rotation file and name it to your desired name ( i.e.: "apache2" to "zzz_apache2" ... in your case maybe: DOMAIN_NAME.apache2 ). When you rename these files they are still executed, so you might want to delete doubles with different names, so your logrotation doesn't do the same job twice, when rotating the logs.
 
Back
Top