Recall & Review
beginner
What is conditional logging in nginx?
Conditional logging in nginx means logging requests only when certain conditions are met, like logging errors but not successful requests.
Click to reveal answer
beginner
Which nginx directive is used to control conditional logging?
The
access_log directive with a condition parameter controls conditional logging.Click to reveal answer
intermediate
How do you disable logging for requests with status code 200 in nginx?
Use
access_log /path/to/log combined if=$loggable; where $loggable is 0 for status 200, for example: map $status $loggable { 200 0; default 1; } and then access_log /path/to/log combined if=$loggable;Click to reveal answer
intermediate
What is the purpose of the
map directive in conditional logging?The
map directive creates a variable based on conditions, which can be used to decide if logging should happen.Click to reveal answer
intermediate
Can you log only error responses (status 400 and above) in nginx?
Yes, by using a
map to set a variable to 1 for status codes 400 and above, then using access_log with if to log only when that variable is 1.Click to reveal answer
Which directive controls logging in nginx?
✗ Incorrect
The
access_log directive controls logging of client requests.How do you disable logging for certain requests in nginx?
✗ Incorrect
You can disable logging conditionally using
access_log /path/to/log combined if=$condition;.What does the
map directive do in conditional logging?✗ Incorrect
map creates variables that help decide logging conditions.To log only error responses (status 400+), what condition should be set?
✗ Incorrect
You set a condition to log when status is 400 or higher.
Which of these is a valid way to conditionally log in nginx?
✗ Incorrect
access_log supports conditional logging with the if parameter.Explain how to set up conditional logging in nginx to log only requests with status codes 400 and above.
Think about how to create a variable that marks error responses and use it in access_log.
You got /3 concepts.
Describe the role of the access_log directive and how it can be customized for conditional logging.
Focus on how access_log controls logging and how conditions affect it.
You got /3 concepts.