implementation of access.log with if condition

lifeisjustabout nginx-forum at forum.nginx.org
Mon Jul 31 09:35:47 UTC 2017


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;
    }

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,275761,275761#msg-275761



More information about the nginx mailing list