0

One of the production servers at my work has a /varlog/apache2 directory that looks like this:

servername.com-access.log
rotated/servername.com-access.log-20190127
rotated/servername.com-access.log-20190126.gz
rotated/servername.com-access.log-20190125.gz
...

I like this approach and want to duplicate it on a personal server but it's not clear to me how this might be done.

My personal server is just logging everything to website.com-access.log. It's not rotating the log files and using this approach the log file is liable to get very big and I just don't like it.

On the production server there's a /etc/logrotate.d/apache2 file with the following contents:

/var/log/apache2/*.log {
        daily
        missingok
        rotate 365
        compress
        delaycompress
        dateext
        olddir rotated
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                if /etc/init.d/apache2 status > /dev/null ; then \
                    /etc/init.d/apache2 reload > /dev/null; \
                fi;
        endscript
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi; \
        endscript
}

I copied that file to my personal server and thought it'd magically start working as above but it isn't. Does logrotate need to be restarted for the changes to take effect or am I missing something?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.