Welcome! Log In Create A New Profile

Advanced

log_format and parsed request - how?

Posted by sergiks 
log_format and parsed request - how?
April 06, 2012 05:10AM
How to set a custom log format for nginx, so that request got parsed and its parts are logged separate?

We serve a picture file to count mail opens. The url to the picture varies, but follows the rule:
http://www.server.com/counter/XXXXX/YYYYY/dailymail.gif
XXXXX - id of email campaign; YYYYY - recipient id.

There's a separate log for /counter location, which I'd like to give a format like
XXXXX YYYYY DATETIME

Location section looks like
location ~* ^counter/([0-9]+)/([^/]+)/dailymail\.gif$ {
access_log /var/log/mailopened.log
alias /var/www/site.com/1x1.gif?cid=$1&uid=$2&type=daily;
}

So I have the values in variables $1 and $2. How can I use them in the log format?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 120
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready