Use this script and put this in the Nginix Configuration file. You must have a knowledge in Nginix configuration in order to understand this.
Specific file
map $request $DisableFileNameLogging{
~*filename1.php 0;
~*filename2.php 0;
~*filename3.php 0;
default 1;
}
server{
access_log /www/wwwlogs/filename.log combined if=$DisableFileNameLogging;
}
map variable should be outside the server. Do not forget to add combined keyword.
In ~*filename1.php 0; # 0 means disabled or off, 1 means enabled or on
Put 1 if you want specific file to enable logging in the map $request $DisableFileNameLogging
For Specific IP Address:
map $request $DisableIPLogging{
0.0.0.0 0;
127.0.0.0 0;
198.168.0.1 0;
default 1;
}
server{
access_log /www/wwwlogs/filename.log combined if=$DisableIPLogging;
}
Combination of Specific File and Specific IP Address
map $request $DisableFileNameLogging{
~*filename1.php 0;
~*filename2.php 0;
~*filename3.php 0;
default 1;
}
map $request $DisableIPLogging{
0.0.0.0 0;
127.0.0.0 0;
198.168.0.1 0;
default 1;
}
server{
set $DisableLogCond1 1;
if ($DisableFileNameLogging = 0){
set $DisableLogCond1 0;
}
if ($DisableIPLogging = 0){
set $DisableLogCond1 0;
}
access_log /www/wwwlogs/test_bwa.bookingwebapp.com.log combined if=$DisableLogCond1;
}
You can also visit this url for Apache Web Serve Guide
https://www.aapanel.com/forum/d/22653-guide-to-disable-specific-file-from-logging-in-apache-file-log