Log to a file inside a location block?

Thomas Nyberg tomnyberg at gmail.com
Sat Apr 23 19:35:17 UTC 2016


Is there any way to log to a file which location block is taken? I've
had times when I've messed up regular expressions in location blocks and
it was difficult to track down the issue. Is there any option equivalent
to this pseudocode?

location ~ ^/prepend(a|b) {
    logtofile "/prepend(a|b)" filepath;
    # Continue normal stuff...

Of course logtofile could also be a "print" or really anything that gets
the information out somewhere.

My nginx version is the following:

$ nginx -v
nginx version: nginx/1.4.6 (Ubuntu)

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:        14.04
Codename:       trusty

Thanks for any help!


More information about the nginx mailing list