how do i rotate my apache logs - Printable Version +- Linux-Noob Forums (https://www.linux-noob.com/forums) +-- Forum: Linux Server Administration (https://www.linux-noob.com/forums/forum-8.html) +--- Forum: LAMP (https://www.linux-noob.com/forums/forum-83.html) +--- Thread: how do i rotate my apache logs (/thread-2253.html) Pages:
1
2
|
how do i rotate my apache logs - anyweb - 2006-01-15 hi all, i'm looking for some guidance as to the best way to rotate my apache logs, they are now large.... i want to retain the data as much as possible, any advice ? Code: -rw-r--r-- 1 root root 0 Jan 10 21:34 access_bad.log cheers anyweb how do i rotate my apache logs - znx - 2006-01-15 First off, there are replacements to the basic syslog (or syslog-ng) that have builtin logrotating skills but anyway... its easy to do. First install "logrotate", this is the utility for rotating logs. Example /etc/logrotate.conf Code: # rotate log files weekly Ok so thats the default for packages, now lets create a file for apache /etc/logrotate.d/apache Code: /var/log/apache/*log { Then make a cron entry /etc/cron.daily/logrotate.cron (in daily in case you switch to daily rotation and forget the cron like i do ;)) Code: #! /bin/sh You will need to touch up on the paths for your system but should be it. :) weee how do i rotate my apache logs - anyweb - 2006-01-25 ok thanks znx done, now what i'm seeing is this Quote:[anyweb@www ~]$ ls -al /usr/local/apache/logs/total 762196 does that look correct to you ? cheers anyweb how do i rotate my apache logs - znx - 2006-01-25 Er yes .. but only if it was instantly after the rotation, if not it looks like your apache isn't logging again, this is an issue with 1) your httpd.conf either moving the logs elsewhere or not logging at all 2) you failed to reload apache on the log rotation Also I note that you chose not to compress (which is possibly a good idea, as those logs will take a year to compress ;)) If 1) mod your apache conf and restart it. If 2) restart apache manually to get it logging again and look at the line just after "postrotate". Hope this helps how do i rotate my apache logs - anyweb - 2006-01-25 ok heres the log part of httpd.conf look ok ? cheers anyweb Quote:# Possible values include: debug, info, notice, warn, error, crit,# alert, emerg.after restarting apache i now get Quote:-rw-r--r-- 1 root root 17368 Jan 25 15:31 access_log-rw-r--r-- 1 root root 487170458 Jan 25 15:31 access_log.1 i think that means its working now, but why didnt it work before ? how do i rotate my apache logs - znx - 2006-01-25 Quote:i think that means its working now, That means that the postrotate failed, what did you use for the postrotate? For instance, if you never start apache with an initscript, what I have above wouldn't work, if you use apachectl then thats the line you want. Basically you need to reload (or restart if you wish but its not needed) apache once you "steal" its log files with logrotate. Ensure that the postrotate line actually works :) how do i rotate my apache logs - anyweb - 2006-01-25 ok znx i'll check it heres the code Quote:/usr/local/apache/logs/*log { missingok testing... Code: [root@www longhorn]# /usr/local/apache/bin/apachectl reload > /dev/null 2>&1 || true cheers anyweb how do i rotate my apache logs - znx - 2006-01-25 Via some live IRC stuff :P snip'd btw Code: <anyweb> [root@www longhorn]# /usr/local/apache/bin/apachectl reload > /dev/null 2>&1 || true ain't irc great :) Thus: Code: /usr/local/apache/logs/*log { how do i rotate my apache logs - anyweb - 2006-01-25 sorted thanks again znx :) how do i rotate my apache logs - anyweb - 2006-11-01 yet another problem after upgrading to fcr5 on the webserver, and adding logrotate again i tried to manually run webalizer today and get 'no valid records found' Code: [root@www ~]# /usr/bin/webalizer [root@www ~]# cd /usr/local/apache/logs/ here's the contents of the logs dir Quote:[root@www logs]# ls -altotal 164380 as i can see it's rotating the logs alright but it's not looking right at all, hence the webalizer failure the webalizer.conf file seems to be looking at one file only so how do i get it to work with rotated log files Quote:# LogFile defines the web server log file to use. If not specified# here or on on the command line, input will default to STDIN. Ifany ideas ? cheers anyweb |