# How to force nginx do return 204 and log it into access log?

**URL:** <https://www.ruby-forum.com/t/how-to-force-nginx-do-return-204-and-log-it-into-access-log/187703>\
**Category:** NGINX\
**Created:** [April 28, 2010, 2:53am UTC](https://www.ruby-forum.com/t/how-to-force-nginx-do-return-204-and-log-it-into-access-log/187703 "2010-04-28T02:53:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![theromis1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/0ea827/32.png) [@theromis1](https://www.ruby-forum.com/u/theromis1)\
**Post date:** [April 28, 2010, 2:53am UTC](https://www.ruby-forum.com/t/how-to-force-nginx-do-return-204-and-log-it-into-access-log/187703/1 "2010-04-28T02:53:09Z")

</div>

Hi,

I’m trying to implement logic which apache making return status 204  
instead of 200 and log it into access log.  
It doing “RedirectMatch 204 xxxxx.gif$”  
for nginx I have created this part of config which working very close to  
above:

```auto
        if ( $request_uri ~ xxxxx.gif ) {
              return 204;
        }
        location ~ xxxx.gif {
            log_format special-v4 "$msec\t$args\t$http_cookie";
            access_log /path/to/access.log special-v4;
            empty_gif;
            internal;
        }
```

so it works but not writing into log.

```auto
Next one writing into log but not giving response 204:
        location ~ xxxx.gif {
            log_format special-v4 "$msec\t$args\t$http_cookie";
            access_log /path/to/access.log special-v4;
            empty_gif;
            internal;
            return 204;
        }
```

My question: is it possible to have ability write access log and have  
retcode 204 without binary modification custom modules?

Posted at Nginx Forum:

> **[how to force nginx do return 204 and log it into access log?](https://forum.nginx.org/read.php?2,80140,80140#msg-80140)**
>
> Hi, I'm trying to implement logic which apache making return status 204 instead of 200 and log it into access log. It doing "RedirectMatch 204 xxxxx.gif$" for nginx I have created this part of config which working very close to above:...
