打开D:\apache\conf下的httpd.conf文件, 一、查找到: 方法1(不分网站生成):CustomLog logs/access.log common 然后将其改写成: CustomLog |bin/rota...
打开D:\apache\conf下的httpd.conf文件,
一、查找到:
方法1(不分网站生成):CustomLog "logs/access.log" common
然后将其改写成:
CustomLog "|bin/rotatelogs.exe -l logs/access-%Y-%m-%d.log 86400" common #服务器上所有网站访问情况记录在一个按天生成的日志文件中。
方法2(区分网站生成):在D:\apache\conf\extra\httpd-vhosts.conf中找到你配置网站代码(每个人的配置会略有不同)并增加黄色代码如下所示:
<VirtualHost *:80>
DocumentRoot "d:/web/xxx/"
ServerName xxx.com
ServerAlias www.xxx.com
DirectoryIndex index.html index.php
<Directory "d:/xxx/">
Options FollowSymLinks
AllowOverride all
<RequireAll>
Require all granted
# 屏蔽某一特定IP
Require not ip 171.8.172.102
# 屏蔽某一特定IP段
Require not ip 123.149 171.8 125.41 125.46 61.52 123.60 222.137 123.52 1.192 182.119 123.161 221.15 123.160 27.115.124 42.236.10
</RequireAll>
</Directory>
# 每天访问情况记录到该网站特定日志文件中
CustomLog "logs/xxx.log" combined
</VirtualHost>二、查找到:
ErrorLog "logs/error.log"
然后将其改写成:
ErrorLog "|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 86400"
三、保存并重启apache,然后在D:\apache\logs下相应生成了如access-2022-03-25.log(或者xxx.log)和error-2022-03-25.log等按年月日或特定网站生成的系列日志文件。