# Record log of full error response?

**URL:** <https://www.ruby-forum.com/t/record-log-of-full-error-response/223229>\
**Category:** NGINX\
**Created:** [September 26, 2012, 12:15pm UTC](https://www.ruby-forum.com/t/record-log-of-full-error-response/223229 "2012-09-26T12:15:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [September 26, 2012, 12:15pm UTC](https://www.ruby-forum.com/t/record-log-of-full-error-response/223229/1 "2012-09-26T12:15:30Z")

</div>

Hello nginxers,

I’ve read about the error\_page[1] config setting and it’s great. However  
serving a custom page instead of the error and just storing the error  
code in an entry in /var/nginx/log/error.log is not enough for me: I  
need to log the full page (the response besides the http status code).

Is there any way to do this? Any config setting I missed? Or any nginx  
module that allows it?

Thanks,  
Andres

[1] [http://wiki.nginx.org/HttpCoreModule#error\_page](http://wiki.nginx.org/HttpCoreModule#error_page)

---

<div class="post-metadata">

**Author:** ![Andres\_GSAragonese](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@Andres\_GSAragonese](https://www.ruby-forum.com/u/Andres_GSAragonese)\
**Post date:** [September 26, 2012, 2:28pm UTC](https://www.ruby-forum.com/t/record-log-of-full-error-response/223229/2 "2012-09-26T14:28:11Z")

</div>

> serving a custom page instead of the error and just storing the error code  
> in an entry in /var/nginx/log/error.log is not enough for me: I need to  
> log the full page (the response besides the http status code).  
> Is there any way to do this? Any config setting I missed?

This suggests your are using dynamic language (like php) for serving  
error  
pages, right?  
While it probably could be done with nginx itself (with using lua/perl  
modules) in case of php you could just buffer the whole output (  
[PHP: ob\_start - Manual](http://php.net/manual/en/function.ob-start.php) ) and store wherever you  
want.

rr

---

<div class="post-metadata">

**Author:** ![Andres\_GSAragonese](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@Andres\_GSAragonese](https://www.ruby-forum.com/u/Andres_GSAragonese)\
**Post date:** [September 26, 2012, 8:36pm UTC](https://www.ruby-forum.com/t/record-log-of-full-error-response/223229/3 "2012-09-26T20:36:49Z")

</div>

On 26/09/12 13:27, Reinis R. wrote:

> > serving a custom page instead of the error and just storing the error  
> > code in an entry in /var/nginx/log/error.log is not enough for me: I  
> > need to log the full page (the response besides the http status code).  
> > Is there any way to do this? Any config setting I missed?
> 
> This suggests your are using dynamic language (like php) for serving  
> error pages, right?

Why?

No. I’m using a VM (that allows dynamic and static languages on top, but  
the question of what kind of typing my language has I guess is already  
out of topic).

> While it probably could be done with nginx itself (with using lua/perl  
> modules) in case of php you could just buffer the whole output (  
> [PHP: ob\_start - Manual](http://php.net/manual/en/function.ob-start.php) ) and store wherever you  
> want.

I’m using fastcgi for the communication between nginx and the  
application server.

Do you think there is some setting in the fastcgi configuration that  
would help me?

Thanks

---

<div class="post-metadata">

**Author:** ![Andres\_GSAragonese](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@Andres\_GSAragonese](https://www.ruby-forum.com/u/Andres_GSAragonese)\
**Post date:** [September 27, 2012, 1:08am UTC](https://www.ruby-forum.com/t/record-log-of-full-error-response/223229/4 "2012-09-27T01:08:35Z")

</div>

> I’m using fastcgi for the communication between nginx and the application  
> server.  
> Do you think there is some setting in the fastcgi configuration that would  
> help me?

You can try to use fastcgi\_store (  
[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpFastcgiModule#fastcgi_store) ) - it allows  
nginx  
to store the response from backend locally.

rr

---

<div class="post-metadata">

**Author:** ![Andres\_GSAragonese](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@Andres\_GSAragonese](https://www.ruby-forum.com/u/Andres_GSAragonese)\
**Post date:** [September 26, 2012, 8:40pm UTC](https://www.ruby-forum.com/t/record-log-of-full-error-response/223229/5 "2012-09-26T20:40:20Z")

</div>

On 26/09/12 19:35, Andres G. Aragoneses wrote:

> On 26/09/12 13:27, Reinis R. wrote:
> 
> > > serving a custom page instead of the error and just storing the error  
> > > code in an entry in /var/nginx/log/error.log is not enough for me: I  
> > > need to log the full page (the response besides the http status code).  
> > > Is there any way to do this? Any config setting I missed?
> > 
> > This suggests your are using dynamic language (like php) for serving  
> > error pages, right?

BTW, I’m not trying to log the error page I want to serve, but the error  
page I got from the fastcgi source.

---

<div class="post-metadata">

**Author:** ![Andres\_GSAragonese](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@Andres\_GSAragonese](https://www.ruby-forum.com/u/Andres_GSAragonese)\
**Post date:** [September 28, 2012, 2:37am UTC](https://www.ruby-forum.com/t/record-log-of-full-error-response/223229/6 "2012-09-28T02:37:41Z")

</div>

On 27/09/12 00:08, Reinis R. wrote:

> > I’m using fastcgi for the communication between nginx and the  
> > application server.  
> > Do you think there is some setting in the fastcgi configuration that  
> > would help me?
> 
> You can try to use fastcgi\_store (  
> [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpFastcgiModule#fastcgi_store) ) - it allows  
> nginx to store the response from backend locally.

Thanks Reinis, I’ll give that a go.
