Nginx Common Log Segmentation method Nginx Apache nginx php nginx rewrite

Source: Internet
Author: User
Mode one: Nginx cronolog log partition configuration document, according to the following method, split the Nginx access log every minute.1. nginx Log configuration access_log access_log/data/access_log_pipe main;2. Create a named pipe first mkfifo/www/Log/access_log_pipe3. Configuration Cronolog:nohup Cat/data/access_log_pipe |/usr/local/sbin/cronolog/data/Log/domain.access_%Y%m%d%H%M.Log&4. Start nginx/usr/Local/nginx/sbin/nginx Note: Cronolog must be installed before Nginx boot without installing cronolog, you need to install wget HTTP first://cronolog. org/download/cronolog-1.6.2. Tar.gztar ZXVF cronolog-1.6.2. TAR.GZCD cronolog-1.6.2./configure makemake Install mode two: Hourly task to add timed tasks, execute a script, you can achieve the hour log split log_dir= "/var/log/nginx"Date_dir= ' date +%Y/%m/%d/%H'/bin/mkdir-p${log_dir}/${date_dir}>/dev/null 2>&1/BIN/MV${log_dir}/access.log${log_dir}/${date_dir}/ACCESS.LOGKILL-USR1 ' Cat/opt/nginx/logs/nginx.pid ' way three: Use the logrotate to do the Nginx log poll logrotate look at the name to know is dedicated to do log polling, only the task configuration placed in/ etc/logrotate.d/, the task will be completed automatically, and no installation, the system comes with, it is recommended to use. Vi/etc/logrotate.d/nginx/usr/local/nginx/logs/www.willko.cn.log/ Usr/local/nginx/logs/nginx_error.log {notifempty daily sharedscripts postrotate/bin/kill-usr1 '/bin/cat /usr/local/nginx/nginx.pid ' Endscript} Multiple logs are separated by a space, notifempty if the log is empty do not poll for scripts executed once per day Postrotate log polling this way, automatic polling occurs every day. , Generate Nginx.log.1-n something: Test method one with JMeter, new thread Group: Thread number 200, loop 150, new HTTP request, request Nginx picture, request 30,000 times, failed 326 times, the background form 5 files, line number as follows: 2868 Access_201112182030.log 7777 access_201112182031.log 7626 access_201112182032.log 7873 access_201112182033.log 353 0 Access_201112182034.log 29674 Total did not lose the log because of the Shard file.

The above describes the Nginx common log segmentation method, including nginx aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.