Use logrotate to poll nginx and Apache logs

Source: Internet
Author: User
Tags apache log

Use logrotate to poll nginx and Apache Log document directories [Hide]
    • Configure nginx
    • Configure Apache

Using logrotate to poll logs is convenient and easy to configure.

Configure nginx

1. Create the/etc/logrotate. d/nginx file.

    1. VI/etc/logrotate. d/nginx

2. Write the following content:

    1. /Var/log/nginx/* log {
    2. Daily
    3. Rotate 10
    4. Missingok
    5. Notifempty
    6. Compress
    7. Sharedscripts
    8. Postrotate
    9. [! -F/var/run/nginx. pid] | kill-usr1 'cat/var/run/nginx. PID'
    10. Endscript
    11. }

Note:
/Var/log/nginx/* log: The Log Path needs to be poll.
Daily: Round Robin every day
Rotate 10: Keep up to 10 scrolling logs
Missingok: If the log is lost, no error is reported to continue rolling the next log.
Receivempty: Do not scroll when the log is empty on the current day
Compress: Old logs are compressed by gzip by default.
/Var/run/nginx. PID: nginx master process PID

Configure Apache
    1. /Var/log/httpd/* log {
    2. Missingok
    3. Notifempty
    4. Sharedscripts
    5. Postrotate
    6. /Sbin/service httpd reload>/dev/null 2>/dev/null | true
    7. Endscript
    8. }

For more information, see https://www.centos.bz/2011/12/logrotate-nginx-log/.

Use logrotate to poll nginx and Apache logs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.