Configure Apache access logs and log cuts

Source: Internet
Author: User

Configure Apache access logs and log cuts


1. Open the Apache master configuration file, command:vim/usr/local/apache2/conf/httpd.conf, locate the Log_config_module module, You can see two logformat(log format) as shown in:

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8E/5F/wKioL1i-xNOTigYyAAAdvEazfcE062.png-wh_500x0-wm_ 3-wmp_4-s_1863003497.png "title=" 11.PNG "alt=" Wkiol1i-xnotigyyaaadveazfce062.png-wh_50 "/>

2. Add the Custom Logformat (log format), named aming as shown in the following:

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8E/5F/wKioL1i-xXqSKEzQAAAqHYNYTRo642.png-wh_500x0-wm_ 3-wmp_4-s_3239535179.png "title=" 22.PNG "alt=" Wkiol1i-xxqskezqaaaqhynytro642.png-wh_50 "/>

Save Exit!

3. Open the Virtual host configuration file, command:vim/usr/local/apache2/conf/extra/httpd-vhosts.conf, find <VirtualHost*:80> under the Customlog It open ( remove the # before it ), set the access log to the stored directory /tmp/1.log and the name aming, as shown in:

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8E/61/wKiom1i-xaigfUDXAAAawfvCWgU682.png-wh_500x0-wm_ 3-wmp_4-s_4001790266.png "title=" 33.PNG "alt=" Wkiom1i-xaigfudxaaaawfvcwgu682.png-wh_50 "/>

4. then, save the exit! Check the Apache configuration for errors, command:/usr/local/apache2/bin/apachectl –T ; Reload under Apache, command:/usr/local/apache2/bin/apachectl Graceful.

5. Log in to the Web page, refresh, and then view the logs below, command:cat/tmp/1.log.

6. The following is a log cut, cutting reasons: To avoid long access to generate a large number of logs resulting in insufficient disk space. Open the virtual host configuration file, and modify the following to separate the access logs generated daily into multiple files, which command:

Customlog "|/usr/local/apache2/bin/rotatelogs-l /tmp/access_%y%m%d_log 86400" aming env=! Image-request(do not record pictures) separates the generated log files into dates. As shown in the following:

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/8E/5F/wKioL1i-xgTyl7YZAAAdfjW43X8906.png-wh_500x0-wm_ 3-wmp_4-s_2198695750.png "title=" 44.PNG "alt=" Wkiol1i-xgtyl7yzaaadfjw43x8906.png-wh_50 "/>

7. and then, Save Exit! Check under apache /usr/local/apache2/bin/ Apachectl – t apache /usr/local/apache2/bin/apachectl  Graceful

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8E/5F/wKioL1i-xiyxKqCcAAAS7oxYLV4304.png-wh_500x0-wm_ 3-wmp_4-s_1587169121.png "title=" 55.PNG "alt=" Wkiol1i-xiyxkqccaaas7oxylv4304.png-wh_50 "/>

You can see the log cut by day!



Configure Apache access logs and log cuts

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.