0
0
Nginxdevops~20 mins

Why logging tracks server behavior in Nginx - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Nginx Logging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why does Nginx use access logs?

What is the main purpose of the access.log file in Nginx?

ATo store the server's configuration files
BTo save the server's error messages only
CTo record every request made to the server for monitoring and troubleshooting
DTo cache website content for faster delivery
Attempts:
2 left
💡 Hint

Think about what information helps you understand who visited your website and when.

💻 Command Output
intermediate
2:00remaining
Output of Nginx error log on startup failure

What output will you see in the Nginx error log if the server fails to start due to a syntax error in the configuration?

Nginx
nginx -t
A"nginx: [emerg] unknown directive \"bad_directive\" in /etc/nginx/nginx.conf:10"
B"nginx: configuration file /etc/nginx/nginx.conf test is successful"
C"nginx: [warn] deprecated directive used in /etc/nginx/nginx.conf"
D"nginx: [error] failed to bind to port 80"
Attempts:
2 left
💡 Hint

Look for messages indicating a syntax problem in the config file.

Configuration
advanced
2:00remaining
Configuring Nginx to log client IP and request time

Which Nginx log_format configuration correctly logs the client IP and request processing time?

Alog_format custom '$remote_addr - $request_time "$request"';
Blog_format custom '$remote_user - $request_time "$request"';
Clog_format custom '$remote_addr - $request_length "$request"';
Dlog_format custom '$remote_addr - $upstream_response_time "$request"';
Attempts:
2 left
💡 Hint

Remember, $remote_addr is client IP and $request_time is request duration.

Troubleshoot
advanced
2:00remaining
Diagnosing missing logs in Nginx

You notice that Nginx is not writing any entries to the access.log. What is the most likely cause?

AThe <code>error_log</code> level is set to <code>info</code>
BThe <code>access_log</code> directive is missing or commented out in the server block
CThe Nginx service is running with root privileges
DThe server is running out of disk space
Attempts:
2 left
💡 Hint

Check if logging is enabled in the configuration.

Best Practice
expert
2:00remaining
Best practice for rotating Nginx logs

What is the recommended way to rotate Nginx logs without stopping the server?

ADisable logging during peak hours to avoid large log files
BManually delete the log files and restart Nginx
CConfigure Nginx to write logs to a database instead of files
DUse the <code>logrotate</code> tool with a postrotate script that sends <code>nginx -s reopen</code>
Attempts:
2 left
💡 Hint

Think about how to safely tell Nginx to start writing to new log files.