N
N
NOONE2017-07-19 15:25:07
Nginx
NOONE, 2017-07-19 15:25:07

How to disable logging 200-300 codes in nginx?

Good evening, has anyone faced this problem? you need to disable logging for 200 and 300 codes, leave only 5XX and 4XX, is there any solution for this task?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2017-07-19
@Djam36

The documentation contains your example:

map $status $loggable {
    ~^[23]  0;
    default 1;
}

access_log /path/to/access.log combined if=$loggable;

When HTTP status codes (internal variable $status) are 2xx or 3xx, i.e. starts with the number 2 or 3, the variable $loggabletakes the value 0. In the ifdirective parameter, a access_logzero value disables logging in these cases.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question