Log file rotation failed!

This issue comes very often. When attempting to check on the "Log file rotation enabled?" option, it gives the following error:

Setting up log file rotation ..
.. Log file rotation failed! : .. the log file /var/log/virtualmin/domain.com_access_log is already being rotated at /usr/libexec/webmin/web-lib-funcs.pl line 1427.
Saving server details ..
.. done

To address this issue we usually remove the .conf file for the website in the /etc/logrotate.d directory, however this time there is no such file for the domain name. But this issue is not about this particular case, because there tons of support requests in the issues queue and forums for the same problem and I believe it is high time for *min team to properly address this issue.

Status: 
Closed (duplicate)

Comments

Turns out the .conf file for completely another domain had references to ALL the domains on the system. Which really sucks as we have to now delete the file and go through each domain creating log rotation again.

I am not sure how a single domains log rotation conf file ended up referencing all other domains on the system and if this a default behavior (should not), but one of possible reasons is that all the domains in this particular system have been restored from backup files. However, the Virtualmin should properly create log rotation file anyway, including the cases when the domains are restored from backup files.

I've deleted all domain (virtual server)-related .conf files in the /etc/logrotate.d directory and started to disable and re-enable the Apache website enabled?, because for unknown reason the option for log rotation is bound to this feature and appears only when it is unchecked. The first .conf file has been created successfully, but unfortunately the reference to the second one and all consecutive domains (virtual servers) are automatically added to the first file whereas it was expected to create new .conf files for each domain separately.

Here is the content of the /etc/logrotate.conf if it helps troubleshooting this problem:

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
dateext

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.
/var/log/procmail.log {
rotate 5
daily
compress
}

Howdy -- out of curiosity, are you able to disable the log rotation feature using the command line?

For example, are you able to run "virtualmin disable-feature --logrotate --domain example.com"?

I'd be curious if you could use that to disable the feature for all domains, and then after verifying that there are no entries in /etc/logrotate.d, use the same functionality to re-enable it.

Per your recommendation I've used the following command first:

virtualmin disable-feature --logrotate --all-domains

Unfortunately, it didn't delete that single .conf file for all domains, so I removed it manually. Then I fired up this one:

virtualmin enable-feature --logrotate --all-domains

which created again the single file with references to all domains names. Has something changed on RHEL/CentOS 7.x? Because on the 6.x based Virtualmin servers each domain (virtual server) had its own conf file.