Ticket #2097 (reopened enhancement)
There is no log rotation for apache logs
| Reported by: | aseques | Owned by: | benedikt |
|---|---|---|---|
| Priority: | patch | Milestone: | ispCP ω 1.1.0 |
| Component: | Config Files | Version: | ispCP ω 1.0.3 |
| Severity: | Medium | Keywords: | |
| Cc: |
Description
I've been looking at how are working the rotation/stats with the apache logs, and there are a couple of problems.
In the logrotate.d/ispcp we are rotating /var/log/apache2/users/*.log and also /var/log/apache2/backup/*.perv (i guess this should be prev)
With the proposed change in the ispcp logrotate file, the logs in /var/log/apache2/*.log get rotated too
Also I am checking for "AWSTATS_ACTIVE = yes" (this should be done in a more polite way) and in case awstats is enabled I generate the stats before rotating the logs. The patch should work with rev2346 branch 1.0.3
Attachments
Change History
comment:1 Changed 2 years ago by benedikt
- Milestone changed from Working to ispCP ω 1.0.4
with the "prev" your right.
Apache logrotates are done in the file logrotation file apache2, the modification is welcome.
comment:2 Changed 2 years ago by aseques
The file /etc/logrotate.d/apache2 depends on the distribution you are using. I see two different solutions possible:
1.- We can delete the /etc/logrotate.d/apache2 that gets installed with apache itself (in debian is part of the package) and use the patch I proposed
2.- We can replace the contents of /etc/logrotate.d/apache2 with the new content, and leave /etc/logrotate.d/ispcp as is (except for the perv -> prev change)
/var/log/apache2/users/*.log {
weekly
missingok
rotate 8
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
prerotate
/var/www/ispcp/engine/traffic/ispcp-vrl-traff > /var/log/ispcp/ispcp-vrl-traff.log
endscript
postrotate
/etc/init.d/apache2 reload > /dev/null
endscript
}
Note that I am leaving only 8 days of log history, this might not be enough for you, but since the amount of the logs is huge, it has to be taken in consideration.
comment:3 Changed 2 years ago by benedikt
You're right, the file used is from my distribution and already patched by me. To keep 8 weeks of logs only might be a problem in some contries where logs must be saved further. I keep them for 52 weeks.
comment:5 Changed 2 years ago by benedikt
- Owner changed from nuxwin to benedikt
- Status changed from assigned to new
comment:7 Changed 2 years ago by benedikt
- Priority changed from normal to patch
- Type changed from defect to enhancement
- Severity changed from Don't know to Easy
- Milestone changed from ispCP ω 1.0.4 to ispCP ω 1.0.5
I do not add the patch (attached) to the trunk. It need to be tested, if the overwrite of the apache logrotate will do any harm.
Please test if all distributions are working with the new file.
Commit will postponed to Omega 1.0.5
comment:8 Changed 2 years ago by aseques
About this patch, there's a missing part still. At least in debian, there's a file in /etc/logrotate.d/apache2 that is installed automatically with apache2.2-common. If we rotate apache logs with ispcp's logrotate file, there should be a trigger to detect/delete the old configuration.
comment:11 Changed 22 months ago by benedikt
apache's logrotation file is executed before ispcp's this causes the effect, that ispcp's logrotation for apache files does not rotate because it is not needed. To avoid this, the apache logrotation file need to be removed. Now I'm pretty unsure, if it is a good idea to delete it or comment the content of it for *.log (what will force me to write a parser)
comment:12 Changed 18 months ago by benedikt
- Status changed from assigned to closed
- Resolution set to fixed
Update:
apache's logrotation is executed before ispcp, if exists:
considering log /var/log/apache2/mydomain.tld log needs rotating
now ispcp's logrotation file is executed:
considering log /var/log/apache2/mydomain.tld log does not need rotating not running shared prerotate script, since no logs will be rotated not running shared postrotate script, since no logs were rotated
The current solution is good. We do not need to care about if there is an existing apache logrotation or not (we do already on install when we insert the awstats update path). This bug should be fixed with r2614.
comment:13 Changed 13 months ago by joximu
- Status changed from closed to reopened
- Resolution fixed deleted
I think this is not resolved:
I installed 1spcp 1.0.7 two times and have the etc/logrotate.d/apache2 and ispcp which try to rotate /var/log/apache2/*.log and logrotate does exit:
* /etc/cron.daily/logrotate: error: ispcp:65 duplicate log entry for /var/log/apache2/domain.tld-combined.log run-parts: /etc/cron.daily/logrotate exited with return code 1 *
Obviously there is something wrong with the installation.
at least on Debian lenny....
/Joxi
comment:14 Changed 13 months ago by joximu
- Severity changed from Easy to Medium
- Milestone changed from ispCP ω 1.0.7 to ispCP ω 1.1.0
a "mv /etc/logrotate/apache2 /etc/logrotate/apache2.disabled" should also do the trick.
important is: there should not be two logrotate files/commands/definitions for the same log files....
/J
comment:15 Changed 13 months ago by joximu
... or remove the /var/log/apache2/*log definition of the ispcp logrotate file and change the apache2 logrotate file as in 1.0.7...
comment:16 Changed 11 months ago by benedikt
I prefer your fist idea over the second, since we cannot control awstats execution if we remove the apache2/*.log-rotation from the ispcp file.



