Apache Split Log

Source: Internet
Author: User

When we visit the site there will be records to stay, this is the log file, log information (source IP, access time and other information)


1. The configuration of the log file already exists in the configuration file of the virtual host, we just need to open it to


Vi/usr/local/apache2/conf/extra/httpd-vhosts.conf


There is a common in the log that represents the format of the log and modifies it to combined


650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/8B/23/wKioL1hFlLmDppgtAACEwKbr5jE539.png-wh_500x0-wm_3 -wmp_4-s_928462825.png "style=" Float:none; "title=" 1.png "alt=" Wkiol1hfllmdppgtaacewkbr5je539.png-wh_50 "/>

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/8B/27/wKiom1hFlLuyQpB6AACW37NWVMs062.png-wh_500x0-wm_3 -wmp_4-s_1460624953.png "style=" Float:none; "title=" 2.png "alt=" Wkiom1hflluyqpb6aacw37nwvms062.png-wh_50 "/>

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>



2. You can modify the name of the log


Modify to Test.com-error_log

Test.com-access_log


Default log path in /usr/local/apache2/logs/


650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s2.51cto.com/wyfs02/m02/8b/27/wkiom1hflmajucenaacmqrcjzpc152.png-wh_500x0-wm_3-wmp_4-s_341088372.png "title= "3.png" alt= "Wkiom1hflmajucenaacmqrcjzpc152.png-wh_50"/>



3. Reboot and Reload after Setup


Apachectl-t

Apachectl Graceful


4. Refresh the page


Go to log directory to see if a log file was generated


CD /usr/local/apache2/logs/


LS View file


650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>



Cat Test.com-access_log can view access log messages


Log format:logformat "%h%l%u%t%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ ""


%H Remote Host

%l Remote Login Name

%u Remote user name

%t time, in normal log time format

%T the time, in seconds, that the request took to complete processing

%r the first line of the request, action

Source IP back two are not present, all with--representations (L:u: Represents the user)



650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/8B/23/wKioL1hFlOXQD-t8AAD6Sm4eLZw674.png-wh_500x0-wm_3 -wmp_4-s_2260812398.png "title=" 34.png "alt=" Wkiol1hfloxqd-t8aad6sm4elzw674.png-wh_50 "/>

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>





5. View the capacity of the log file


Wc-l Test.com-access_log


650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>


What should I do to sort the format by time?


Add some content to the virtual host log configuration file


Customlog "| /usr/local/apache2/bin/rotatelogs-l/usr/local/apache2/logs/test.com-access_%Y%m%d_log 86400 "combined


650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s1.51cto.com/wyfs02/m00/8b/27/wkiom1hflp-rweb1aaciosxqlru156.png-wh_500x0-wm_3-wmp_4-s_4167075387.png "title = "4.png" alt= "Wkiom1hflp-rweb1aaciosxqlru156.png-wh_50"/>


Refresh the Web page to generate a log with a date


650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/8B/23/wKioL1hFlQ-igCipAAAOmERYZ14245.png-wh_500x0-wm_3 -wmp_4-s_3854248745.png "title=" 5.png "alt=" Wkiol1hflq-igcipaaaomeryz14245.png-wh_50 "/>


Modify the date, and then refresh the page to see if there is a build log


Date-s "2016-11-21 15:55:20"



650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/8b/27/wkiom1hfltbs5pxfaaannkwjiz4223.png-wh_500x0-wm_3-wmp_4-s_166256326.png "title= "6.png" alt= "Wkiom1hfltbs5pxfaaannkwjiz4223.png-wh_50"/>


Refresh the Web page and generate a new log file



650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m00/8b/27/wkiom1hflt6hbistaaan4qlshbq496.png-wh_500x0-wm_3-wmp_4-s_1725241055.png "title = "7.png" alt= "Wkiom1hflt6hbistaaan4qlshbq496.png-wh_50"/>



Apache Split Log

Related Article

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.