{"id":1380,"date":"2008-09-09T01:16:46","date_gmt":"2008-09-09T01:16:46","guid":{"rendered":"http:\/\/www.icocean.com\/blog\/?p=1380"},"modified":"2008-09-09T01:19:02","modified_gmt":"2008-09-09T01:19:02","slug":"%E9%99%90%E5%88%B6apache%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%E5%A4%A7%E5%B0%8F%E7%9A%84%E6%96%B9%E6%B3%95","status":"publish","type":"post","link":"https:\/\/www.icocean.com\/blog\/?p=1380","title":{"rendered":"\u9650\u5236Apache\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\u7684\u65b9\u6cd5"},"content":{"rendered":"<p>access.log,\u4ef6\u5728 WEB \u670d\u52a1\u5668\u8fd0\u884c\u4e00\u6bb5\u65f6\u95f4\u4e4b\u540e\u4f1a\u8fbe\u5230\u51e0\u5341\u5146\u751a\u81f3\u4e0a\u767e\u5146\uff0c\u5982\u679cApache\u8fd0\u884c\u6709\u9519\u8bef,error.log\u4e5f\u4f1a\u589e\u5927\u5230\u51e0\u5341\u5146\uff0c\u6211\u4eec\u77e5\u9053\u7cfb\u7edf\u8bfb\u5199\u4e00\u4e2a\u5927\u7684\u6587\u672c\u6587\u4ef6\u662f\u975e\u5e38\u8017\u5185\u5b58\u7684\uff0c\u56e0\u6b64\u9650\u5b9a\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\u5341\u5206\u5fc5\u8981\u3002<\/p>\n<p>\u901a\u5e38\u6211\u4eec\u662f\u5728{$apache}\/conf\/httpd.conf\u4e2d\u8bbe\u7f6eApache\u7684\u53c2\u6570\uff0c\u7136\u800c\u6211\u4eec\u5e76\u6ca1\u6709\u53d1\u73b0\u53ef\u4ee5\u8bbe\u7f6e\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\u7684\u914d\u7f6e\u6307\u4ee4\uff0c\u901a\u8fc7\u53c2\u8003http:\/\/httpd.apache.org\/docs\/2.0\/programs\/rotatelogs.html\uff0c\u53ef\u4ee5\u7528apache \u81ea\u5df1\u7684\u7a0b\u5e8f rotatelogs.exe(\u4f4d\u4e8e {$apache}\/bin\/\u76ee\u5f55\u4e0b)\uff0c\u6765\u9650\u5236\u65e5\u5fd7\u6587\u4ef6\u7684\u5927\u5c0f\u3002<\/p>\n<p>Usage: rotatelogs [-l] <logfile> <rotation time in seconds> [offset minutes from UTC] or <rotation size in megabytes><\/p>\n<p>Add this:<br \/>TransferLog &#8220;&#124;rotatelogs \/some\/where 86400&#8221;&nbsp;&nbsp;<br \/>or <br \/>TransferLog &#8220;&#124;rotatelogs \/some\/where 5M&#8221; <br \/>to httpd.conf. The generated name will be \/some\/where.nnnn where nnnn is the system time at which the log nominally starts (N.B. if using a rotation time, the time will always be a multiple of the rotation time, so you can synchronizecron scripts with it). At the end of each rotation time or when the file size is reached a new log is started.<\/p>\n<p>\u5728 Windows \u4e0b\u7684\u8bbe\u7f6e\u4f8b\u5b50\u5982\u4e0b\uff1a<!--more--><\/p>\n<p>\u5c06httpd.conf\u4e2dCustomLog logs\/access.log common \u6539\u6210<\/p>\n<p># \u9650\u5236\u8bbf\u95ee\u65e5\u5fd7\u6587\u4ef6\u4e3a 1M<br \/>CustomLog &#8220;&#124;bin\/rotatelogs.exe -l logs\/access-%Y-%m-%d.log 1M&#8221; common<\/p>\n<p># \u6bcf\u5929\u751f\u6210\u4e00\u4e2a\u8bbf\u95ee\u65e5\u5fd7\u6587\u4ef6<br \/>#CustomLog &#8220;&#124;bin\/rotatelogs.exe -l logs\/access-%Y-%m-%d.log 86400&#8221; common<\/p>\n<p># \u9650\u5236\u9519\u8bef\u65e5\u5fd7\u6587\u4ef6\u4e3a 1M<br \/>ErrorLog &#8220;&#124;bin\/rotatelogs.exe -l logs\/error-%Y-%m-%d.log 1M&#8221;<\/p>\n<p># \u6bcf\u5929\u751f\u6210\u4e00\u4e2a\u9519\u8bef\u65e5\u5fd7\u6587\u4ef6<br \/>#ErrorLog &#8220;&#124;bin\/rotatelogs.exe -l logs\/error-%Y-%m-%d.log 86400&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>access.log,\u4ef6\u5728 WEB \u670d\u52a1\u5668\u8fd0\u884c\u4e00\u6bb5\u65f6\u95f4\u4e4b\u540e\u4f1a\u8fbe\u5230\u51e0\u5341\u5146\u751a\u81f3\u4e0a\u767e\u5146\uff0c\u5982\u679cApache\u8fd0\u884c\u6709\u9519\u8bef, <a href='https:\/\/www.icocean.com\/blog\/?p=1380' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[638,1884,1883,691,1885,52],"class_list":["post-1380","post","type-post","status-publish","format-standard","hentry","category-lamp","tag-apache","tag-limit","tag-log","tag-691","tag-1885","tag-52","category-24-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1380"}],"version-history":[{"count":0,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1380\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}