Welcome! Log In Create A New Profile

Advanced

implementation of access.log with if condition

July 31, 2017 05:35AM
Hi I would like to implement if condition on access and error log. Prior to nginx restart I want nginx to look for first log path location eg. /externalhdd/log/nginx/example.com_access.log, if log doesn't exist use second path which is /var/log/nginx/example.com_access.log I have given like my example. I guess I need some if conditions or something.

server {
listen 80;
server_name example.com;
root /var/www/example.com/public_html;
index index.php;
IF ACCESS LOG EXIST USE THIS PATH
access_log /externalhdd/log/nginx/example.com/logs/example.com_access.log;
IF ACCESS LOG DOESN'T EXIST USE THIS PATH
access_log /var/log/nginx/example.com/logs/example.com_access.log;

error_log /var/www/example.com/logs/example.com_error.log error;

location / {
index index.php index.html;
}
Subject Author Posted

implementation of access.log with if condition

lifeisjustabout July 31, 2017 05:35AM

Re: implementation of access.log with if condition

Igor A. Ippolitov July 31, 2017 06:18AM

Re: implementation of access.log with if condition

lifeisjustabout July 31, 2017 07:08AM

Re: implementation of access.log with if condition

Lucas Rolff July 31, 2017 08:28AM

Re: implementation of access.log with if condition

lifeisjustabout July 31, 2017 10:33AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 174
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready