redislog
syntax: redislog <peer name> <hostname>[:<port>] [<password>]
default: none
severity: mandatory
context: main configuration file
Specifies the name of a log peer, its redis hostname and optional password. Once specified, the peer name can be used in access_redislog directives. hostname can be both domain name and IP address of a destination redis database. A password needs to be specified in plain text as long as requirepass redis configuration directive is used.
access_redislog
syntax: access_redislog *<off>|<peer name>* *<key template>* *[<arguments...>]*
default: none
severity: optional
context: http, server, location
Enables or disables logging into specified redis peer. Once enabled at certain level, same logging settings are inherited by subsequent levels. off argument disables logging into redis for specific location. Multiple peers are allowed at the same location. Log messages are then sent into all specified peers. key template specifies a template for redis database key where log messages will be appended to. Besides standard nginx variable following variables are allowed:
- $redislog_yyyy -- 4 digit number of
current year
- $redislog_yyyymm -- 4 digit number of current year plus 2 digit number of current month
- $redislog_yyyymmdd -- current year, month and day
- $redislog_yyyymmddhh -- current year, month, day and hour
As of version 1.0.1 this directive supports following arguments:
command -- Specifies redis command that will be used to save log messages (APPEND is default). Any command can be used, following are most useful: RPUSH, LPUSH, SADD, SREM, EVALSHA predefinedsha1. Use arg1 in order to specify the first argument of commands with 2 argument (see below).
arg1 -- Specifies the first argument for command with 2 argument, e.g. EVALSHA.
format -- Specifies a log format that will be used to format log messages (default is 'combined').
if -- Specifies an expression for conditional logging. If set, a request will be logged only if this expression evaluates to true (any non-empty value except for literal "0").
ifnot -- Specifies an expression for conditional logging. If set, a request will be logged only if this expression evaluates to false (any empty value or literal "0").
Example:
accessredislog test $servername$redislog_yyyymmdd;
accessredislog test $servername$redislogyyyymmdd ifnot=$uidgot; # Logs only unique visitors
Creates a key for each hostname and each day.
Use redis GET command to retrieve logging data.