0
0
Nginxdevops~5 mins

Log format customization in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of customizing log formats in nginx?
Customizing log formats in nginx helps you record exactly the information you need about requests, making it easier to analyze traffic, debug issues, and monitor performance.
Click to reveal answer
beginner
Which nginx directive is used to define a custom log format?
The log_format directive is used to define a custom log format in nginx.
Click to reveal answer
intermediate
How do you apply a custom log format to an access log in nginx?
You apply a custom log format by specifying its name in the access_log directive, like access_log /path/to/log custom_format_name;.
Click to reveal answer
beginner
What does the variable $remote_addr represent in nginx log formats?
$remote_addr represents the IP address of the client making the request.
Click to reveal answer
intermediate
Give an example of a simple custom log format that logs client IP, request method, and request URI.
Example: <br>log_format simple '$remote_addr - $request_method $request_uri';
Click to reveal answer
Which directive defines a custom log format in nginx?
Alog_format
Baccess_log
Cerror_log
Dserver_name
How do you tell nginx to use a custom log format for access logs?
ABy naming the format in the access_log directive
BBy setting error_log to the format name
CBy using the server_name directive
DBy editing the nginx.conf file header
What does $request_uri log in nginx?
AThe HTTP response status code
BThe full original request URI including arguments
CThe client's IP address
DThe server's hostname
Which variable logs the client's IP address in nginx logs?
A$request_method
B$server_addr
C$host
D$remote_addr
If you want to log the HTTP method used by the client, which variable do you use?
A$body_bytes_sent
B$status
C$request_method
D$remote_user
Explain how to create and apply a custom log format in nginx.
Think about defining the format first, then telling nginx to use it.
You got /4 concepts.
    List common nginx variables used in custom log formats and what they represent.
    Focus on variables that describe the request and response.
    You got /5 concepts.