Some requests from local servers is annoying. Need to separate the logs, then the log can focus on users’ requests.
To separate the log, use apache environment variable, modify at apache config file, change the IP range “192.168.1.10/26” to the corresponding local servers’ IPs.
<If "-R '192.168.1.10/26'">
SetEnv RequestFromLocal
</If>
ErrorLog "|/app/apache/bin/rotatelogs logs/3de_error-%Y-%m-%d.log 86400"
LogFormat "%h %v:%{local}p %l %u %{SSL_PROTOCOL}x %{SSL_CIPHER}x %{User-agent}i %t %{ms}T \"%r\" %>s %b" 3deformat
CustomLog "|/app/apache/bin/rotatelogs logs/3de_access-%Y-%m-%d.log 86400" 3deformat env=!RequestFromLocal
CustomLog "|/app/apache/bin/rotatelogs logs/3de_local-%Y-%m-%d.log 86400" 3deformat env=RequestFromLocal
and then restart apache.
apachectl restart
Key Explanations
- The
!Symbol: Inenv=!, the exclamation mark acts as a “NOT” operator. It ensures only customers hits go to 3de_access-yyyy-mm-dd.log. request from local servers will go to 3de_local-YYYY-mm-dd.logRequestFromLocal - The IP Address
"-R '192.168.1.10/26'", This is CIDR notation.it means if remote address first 26 digit is same as ‘192.168.1.10’, then this variable RequestFromLocal is true. - Performance: This method is handled in-memory and has negligible impact on server performance.
good for 3DX apache