Welcome! Log In Create A New Profile

Advanced

Re: implementation of access.log with if condition

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

As far as I know, it's impossible using Nginx.
But you can archive the same result using only 'access_log' statement
into 'permanent' location.
Just mount your external drive 'nginx' directory over /var/log/nginx like:
mount -o bind /externalhdd/log/nginx/ /var/log/nginx/

If it is unsuitable for you to 'hide' whole directory, you can create
a subdirectory for your logs and bind external hdd dir there:
mount -o bind /externalhdd/log/nginx/ /var/log/nginx/mysitelogs/

Hope this helps.

On 31.07.2017 12:35, lifeisjustabout wrote:
> 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
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
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: 116
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready