0

I am running apache 2.4.9 on ubuntu 14.04. Apache rotates log files and archives them, so I end up with something like: access.log.2.gz, ... access.log.N.gz.

The problem with this is that it is hard to analyze them (I have to unarchive, analyze and remove them). Moreover, I do not really want these logs to lay around on the server (I would rather copy them to my local machine and remove them from server). Right now I am doing this manually, which is not so efficient.

So is there a way to configure apache to automatically send me an email with a log file right after apache rotated it? If this is not really a good idea or there is something better, I am opened to any suggestions

1

From man logrotate.conf

mail address

When a log is rotated out-of-existence, it is mailed to address. If no mail should be generated by a particular log, the nomail directive may be used.

mailfirst

When using the mail command, mail the just-rotated file, instead of the about-to-expire file.

maillast

When using the mail command, mail the about-to-expire file, instead of the just-rotated file (this is the default).

So if you set those options in your logrotate config file(s), and reduce the rotate option to 0 then you should get what you're after.

| improve this answer | |
0

If you use logrotate to rotate the file (probably a great idea)..then you can put in postprocessing in the configuration file for the file being rotated. If this is currently contained in a multiple file rule, then break it down and make the change. This postprocessing could be to send a file to you.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.