MEWBIES@:  Facebook  Twitter  G+  YouTube  DeviantArt  Forum  Wall
 SHARE:
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
   ██                                                                       ██
  █▌                          -   APACHE2 LOGS    -                          █▌
 █▌                                                                           █▌
 █                                                                            ▐▌
 █ Once you feel your server is setup properly you can reduce the load by     ▐▌
 █ disabling some/all of the Apache logs. I like to keep only my error.logs   ▐▌
 █ for trouble shooting since I test install a variety of programs; so I'll   ▐▌
 █ adjust logrotate settings for it. I don't have any need for any of the     ▐▌
 █ other log files so I'll completely disable those (access.log,              ▐▌
 █ other_vhosts_access.log and ssl_access.log). Adjust to your needs. This is ▐▌
 █ how I did it:                                                              ▐▌
 █                                                                            ▐▌
 █ DISABLING AN APACHE2 LOG:                                                  ▐▌
 █ `````````````````````````                                                  ▐▌
 █ Apache2 logs are here:                                                     ▐▌
 █ ls -al /var/log/apache2/                                                   ▐▌
 █                                                                            ▐▌
 █ To find in your own configuration files where it is stated to log, search  ▐▌
 █ your relevant apache configuration files, for example:                     ▐▌
 █ su                                                                         ▐▌
 █ cat /etc/apache2/apache2.conf | grep .log                                  ▐▌
 █ Or search for the name of each log, for example access.log:                ▐▌
 █ cat /etc/apache2/sites-available/default | grep access                     ▐▌
 █                                                                            ▐▌
 █ Or I like this method that gives me a more complete list to go through:    ▐▌
 █ grep -r other_vhosts_access /etc/apache2/*                                 ▐▌
 █ grep -r .log /etc/apache2/*                                                ▐▌
 █                                                                            ▐▌
 █ 1) So from my output above I'll disable logs in these files:               ▐▌
 █ pico /etc/apache2/apache2.conf                                             ▐▌
 █ search for .log (Ctrl+w) or which ever log you want to disable.            ▐▌
 █                                                                            ▐▌
 █ Disable it by 'commenting it out' - adding before the line a: #            ▐▌
 █ It has this:                                                               ▐▌
 █ # Define an access log for VirtualHosts that don't define their own logfile▐▌
 █ CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined          ▐▌
 █ Change it to:                                                              ▐▌
 █ # Define an access log for VirtualHosts that don't define their own logfile▐▌
 █ #CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined         ▐▌
 █                                                                            ▐▌
 █ 2) Then:                                                                   ▐▌
 █ pico /etc/apache2/sites-available/default                                  ▐▌
 █ Comment out this line:                                                     ▐▌
 █ CustomLog /var/log/apache2/access.log combined                             ▐▌
 █                                                                            ▐▌
 █ 3) Then:                                                                   ▐▌
 █ pico /etc/apache2/sites-available/ajaxterm                                 ▐▌
 █ Comment out both of these lines:                                           ▐▌
 █ CustomLog /var/log/apache2/access.log combined                             ▐▌
 █ CustomLog /var/log/apache2/access.log combined env=!dontlog                ▐▌
 █                                                                            ▐▌
 █ Note: Your changes will also show in 'sites-enabled' if you had previously ▐▌
 █ created those as symbolic links (ln -s) for example:                       ▐▌
 █ cat /etc/apache2/sites-enabled/ajaxterm                                    ▐▌
 █                                                                            ▐▌
 █ 4) Then:                                                                   ▐▌
 █ pico /etc/apache2/sites-available/default-ssl                              ▐▌
 █ Comment out both of these lines:                                           ▐▌
 █ CustomLog /var/log/apache2/ssl_access.log combined                         ▐▌
 █ CustomLog /var/log/apache2/access.log combined env=!dontlog                ▐▌
 █                                                                            ▐▌
 █ 5) Then to have the changes take affect:                                   ▐▌
 █ /etc/init.d/apache2 restart                                                ▐▌
 █ If you are running ajaxterm:                                               ▐▌
 █ /etc/init.d/ajaxterm restart                                               ▐▌
 █                                                                            ▐▌
 █ 6) If you would like to test your changes, check the time stamps for the   ▐▌
 █ last 5 entries:                                                            ▐▌
 █ tail -5 access.log                                                         ▐▌
 █ Then open one of your web pages on each site you have enabled, then tail   ▐▌
 █ again, you shouldn't see any new entries:                                  ▐▌
 █ tail -5 access.log                                                         ▐▌
 █                                                                            ▐▌
 █ 7) Then to delete your logs files:                                         ▐▌
 █ Access logs:                                                               ▐▌
 █ rm /var/log/apache2/access.log.*.gz                                        ▐▌
 █ Or to remove including present file:                                       ▐▌
 █ rm /var/log/apache2/access.*                                               ▐▌
 █                                                                            ▐▌
 █ Error logs:                                                                ▐▌
 █ rm /var/log/apache2/error.log.*.gz                                         ▐▌
 █                                                                            ▐▌
 █ Other vhosts logs:                                                         ▐▌
 █ rm /var/log/apache2/other_vhosts_access.*                                  ▐▌
 █                                                                            ▐▌
 █ APACHE LOG ROTATION:                                                       ▐▌
 █ ````````````````````                                                       ▐▌
 █ man logrotate                                                              ▐▌
 █ Or you can view it HERE.                                                   ▐▌
 █ Since I have left error logging enabled, I would like to rotate the log    ▐▌
 █ more often than its default of weekly. To do so we need to change apache2  ▐▌
 █ directives in its logrotate file:                                          ▐▌
 █                                                                            ▐▌
 █ pico /etc/logrotate.d/apache2                                              ▐▌
 █ Has this:                                                                  ▐▌
/var/log/apache2/*.log {
        weekly
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
                        /etc/init.d/apache2 reload > /dev/null
                fi
        endscript
}
 █                                                                            ▐▌
 █ I change these two lines so that it rotates daily and keeps no more than   ▐▌
 █ one file:                                                                  ▐▌
 █         daily                                                              ▐▌
 █         rotate 1                                                           ▐▌
 █                                                                            ▐▌
 █ To test changes, but NOT actually rotate your logs:                        ▐▌
 █ logrotate --debug --force /etc/logrotate.d/apache2                         ▐▌
 █                                                                            ▐▌
 █ To rotate the logs manually:                                               ▐▌
 █ logrotate --force -v /etc/logrotate.d/apache2                              ▐▌
 █                                                                            ▐▌
 █ Or to test rotate all logs handled by logrotate:                           ▐▌
 █ logrotate --debug --force /etc/logrotate.conf                              ▐▌
 █                                                                            ▐▌
 █ So in the end I now have only /var/log/apache2/error.log and its backup    ▐▌
 █ from the day before error.log.1                                            ▐▌
 █                                                                            ▐▌
 █ //----------------------------------------------------------------------   ▐▌
 █                                                                            ▐▌
 █ If you find mistakes, have suggestions, and or questions please post at    ▐▌
 █ mewbies forum HERE - thank you.                                            ▐▌
 █                                                                            ▐▌
 █ Last update on 05 Jul '10                                                  ▐▌
 █                                                                            ▐▌
 █▌                                                                           █▌
  █▌                          -   mewbies.com   -                            █▌
   █▌                                                                       █▌
    ██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██