# Nginx ignores access\_log directive when post\_action specifie

**URL:** <https://www.ruby-forum.com/t/nginx-ignores-access-log-directive-when-post-action-specifie/189388>\
**Category:** NGINX\
**Created:** [May 31, 2010, 2:26am UTC](https://www.ruby-forum.com/t/nginx-ignores-access-log-directive-when-post-action-specifie/189388 "2010-05-31T02:26:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kampers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/54ee81/32.png) [@kampers](https://www.ruby-forum.com/u/kampers)\
**Post date:** [May 31, 2010, 2:26am UTC](https://www.ruby-forum.com/t/nginx-ignores-access-log-directive-when-post-action-specifie/189388/1 "2010-05-31T02:26:04Z")

</div>

Hi,

in the location below nginx writes a custom download log. Everything  
works fine except when there is a post\_action directive.

I seems that nginx skips the access\_log directive but I don’t understand  
why. Any help is greatly appreciated.

Here is the config:

location /download\_intern/ {  
internal;

```
if ($uri ~* ^/download_intern/([0-9]+)/) {
    set $transferID $1;
    set $server $arg_ip;
    set $url $arg_url;
    proxy_pass http://$server:80/$url;
    break;
}

log_format download '$remote_addr [$time_local]

```

$upstream\_cache\_status “$scheme://$host$request\_uri” $status  
[$transferID] $body\_bytes\_sent’;

```
access_log /opt/nginx/logs/server.download_log download;

# without this line the download log file is being written
post_action /done;

```

}

location /done {  
internal;  
# log the transfer on the main server  
proxy\_pass [http://xxx.xxx.xxx.xxx:80/download\_end/?tid=$transferID](http://xxx.xxx.xxx.xxx:80/download_end/?tid=$transferID);  
}

---

<div class="post-metadata">

**Author:** ![kampers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/54ee81/32.png) [@kampers](https://www.ruby-forum.com/u/kampers)\
**Post date:** [February 10, 2012, 7:30am UTC](https://www.ruby-forum.com/t/nginx-ignores-access-log-directive-when-post-action-specifie/189388/2 "2012-02-10T07:30:07Z")

</div>

I am facing the same problem, is there any update on this issue ?

Posted at Nginx Forum:

> **[Re: nginx ignores access\_log directive when post\_action specifie](https://forum.nginx.org/read.php?2,92464,222201#msg-222201)**
>
> Hi, in the location below nginx writes a custom download log. Everything works fine except when there is a post\_action directive. I seems that nginx skips the access\_log directive but I don't understand why. Any help is greatly appreciated. Here is

---

<div class="post-metadata">

**Author:** ![kampers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/54ee81/32.png) [@kampers](https://www.ruby-forum.com/u/kampers)\
**Post date:** [February 10, 2012, 8:32am UTC](https://www.ruby-forum.com/t/nginx-ignores-access-log-directive-when-post-action-specifie/189388/3 "2012-02-10T08:32:03Z")

</div>

Hello!

On Fri, Feb 10, 2012 at 01:29:26AM -0500, rishabh wrote:

> I am facing the same problem, is there any update on this issue ?

Logging happens in a location where request completes, and with  
post\_action it’s the location where post\_action processed.  
So the problem looks like configuration one.

Maxim D.

---

<div class="post-metadata">

**Author:** ![kampers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/54ee81/32.png) [@kampers](https://www.ruby-forum.com/u/kampers)\
**Post date:** [February 20, 2012, 4:19pm UTC](https://www.ruby-forum.com/t/nginx-ignores-access-log-directive-when-post-action-specifie/189388/4 "2012-02-20T16:19:05Z")

</div>

Hello!

On Mon, Feb 20, 2012 at 07:28:52AM -0500, rishabh wrote:

> ```
> set_by_lua_file $logdata /var/www/log.lua;
> 
> ```
> 
> In this case only access2.log(via post\_action) is written and not the  
> default access.log(in http)
> 
> What would be an optimal solution.

If you want request to be logged into two logs, you have to define  
two access\_log directives where requests are logged, i.e.

```
location / {
    access_log /var/log/nginx/access.log;
    access_log /var/log/nginx/access2.log;
    ...
}

```

Maxim D.

---

<div class="post-metadata">

**Author:** ![kampers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/54ee81/32.png) [@kampers](https://www.ruby-forum.com/u/kampers)\
**Post date:** [February 20, 2012, 1:29pm UTC](https://www.ruby-forum.com/t/nginx-ignores-access-log-directive-when-post-action-specifie/189388/5 "2012-02-20T13:29:42Z")

</div>

Hi,

I am trying to log into two files. one default and one custom via  
post\_action.

http {  
access\_log /var/log/nginx/access.log;

server {  
location @postactionlocation {  
set\_by\_lua\_file $logdata /var/www/log.lua;  
access\_log /var/log/nginx/access2.log ‘$logdata’;  
return 444;  
}

location / {  
#someproxypass here  
}

post\_action @postactionlocation;  
}

In this case only access2.log(via post\_action) is written and not the  
default access.log(in http)

What would be an optimal solution.

Thanks

–  
Rishabh

## Maxim D. Wrote:

> post\_action it’s the location where post\_action  
> processed.  
> So the problem looks like configuration one.
> 
> Maxim D.
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,92464,222714#msg-222714](http://forum.nginx.org/read.php?2,92464,222714#msg-222714)
