Bird
Raised Fist0
Nginxdevops~20 mins

Debug mode in Nginx - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Debug Mode Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Enable debug logging in nginx configuration
You want to enable debug logging in nginx to troubleshoot request handling. Which directive correctly enables debug logging in the main nginx configuration file?
Aerror_log /var/log/nginx/error.log debug;
Baccess_log /var/log/nginx/access.log debug;
Clog_level debug;
Ddebug_log /var/log/nginx/debug.log;
Attempts:
2 left
💡 Hint
Debug logging in nginx is controlled by the error_log directive with a specific log level.
💻 Command Output
intermediate
2:00remaining
Check if debug mode is active in nginx
After enabling debug logging, you want to verify if nginx is running with debug mode active. Which command output confirms debug mode is enabled?
Nginx
nginx -V
Adebug=true
Berror_log set to debug
Cdebug_mode=on
Dbuilt with --with-debug
Attempts:
2 left
💡 Hint
Check the nginx build options to see if debug support is compiled in.
Configuration
advanced
3:00remaining
Configure debug logging only for a specific location
You want to enable debug logging only for requests to the /api location in nginx, without affecting other locations. Which configuration snippet achieves this?
A
location /api {
    error_log /var/log/nginx/api_error.log debug;
}
B
error_log /var/log/nginx/api_error.log debug;
location /api {}
C
location /api {
    access_log /var/log/nginx/api_access.log debug;
}
D
location /api {
    debug_log /var/log/nginx/api_debug.log;
}
Attempts:
2 left
💡 Hint
The error_log directive can be set inside a location block to control logging for that location.
Troubleshoot
advanced
3:00remaining
Debug logs not appearing after enabling debug mode
You enabled debug logging in nginx with error_log /var/log/nginx/error.log debug; but no debug messages appear in the log. What is the most likely cause?
AThe log file path is incorrect and nginx cannot write logs
BThe error_log directive must be in the http block, not main
Cnginx was not compiled with --with-debug option
DDebug logging requires restarting the server with --debug flag
Attempts:
2 left
💡 Hint
Check if your nginx binary supports debug mode by build options.
Best Practice
expert
3:00remaining
Best practice for enabling debug mode in production nginx
You need to enable debug logging temporarily on a production nginx server to troubleshoot an issue. What is the best practice to minimize impact?
AEnable debug logging globally and restart nginx to apply changes
BEnable debug logging only for the affected location and reload nginx configuration
CEnable debug logging and leave it on permanently for continuous monitoring
DStop nginx, enable debug logging, then start nginx to avoid partial logs
Attempts:
2 left
💡 Hint
Limit debug logging scope and avoid full restarts in production.

Practice

(1/5)
1. What does enabling debug mode in nginx do?
easy
A. Shows detailed logs to help find problems
B. Stops nginx from running
C. Deletes all log files
D. Automatically fixes errors

Solution

  1. Step 1: Understand debug mode purpose

    Debug mode is designed to provide detailed information about what nginx is doing internally.
  2. Step 2: Identify effect of enabling debug mode

    It shows detailed logs that help find and fix problems in nginx configuration or operation.
  3. Final Answer:

    Shows detailed logs to help find problems -> Option A
  4. Quick Check:

    Debug mode = detailed logs [OK]
Hint: Debug mode means detailed logs for troubleshooting [OK]
Common Mistakes:
  • Thinking debug mode stops nginx
  • Believing debug mode deletes logs
  • Assuming debug mode auto-fixes errors
2. Which is the correct syntax to enable debug mode in nginx's error log?
easy
A. error_log debug /var/log/nginx/error.log;
B. error_log /var/log/nginx/error.log info;
C. error_log /var/log/nginx/error.log debug;
D. error_log /var/log/nginx/error.log off;

Solution

  1. Step 1: Recall error_log syntax

    The correct syntax is: error_log <file_path> <level>; where level can be debug, info, etc.
  2. Step 2: Identify correct option

    error_log /var/log/nginx/error.log debug; uses correct order: file path first, then debug level.
  3. Final Answer:

    error_log /var/log/nginx/error.log debug; -> Option C
  4. Quick Check:

    error_log file_path debug; = error_log /var/log/nginx/error.log debug; [OK]
Hint: error_log path then level debug; is correct syntax [OK]
Common Mistakes:
  • Swapping file path and level order
  • Using info instead of debug for debug mode
  • Setting level to off disables logging
3. Given this nginx config snippet:
error_log /var/log/nginx/error.log debug;
server {
  listen 80;
  server_name example.com;
}

What will happen when nginx receives a request?
medium
A. Detailed debug logs will be written to /var/log/nginx/error.log
B. No logs will be created
C. Only error messages will be logged
D. Nginx will refuse connections

Solution

  1. Step 1: Analyze error_log level

    The error_log is set to debug level, which logs detailed info about requests.
  2. Step 2: Understand effect on request handling

    When nginx receives a request, it logs detailed debug info to the specified file.
  3. Final Answer:

    Detailed debug logs will be written to /var/log/nginx/error.log -> Option A
  4. Quick Check:

    debug level logs detailed info [OK]
Hint: debug level logs detailed info on requests [OK]
Common Mistakes:
  • Thinking debug disables logging
  • Assuming only errors are logged
  • Believing nginx refuses connections with debug
4. You set error_log /var/log/nginx/error.log debug; but see no debug logs. What is a likely cause?
medium
A. Debug mode disables logging
B. Nginx was not reloaded after config change
C. The log file path is missing
D. The debug level is misspelled

Solution

  1. Step 1: Check if config changes are active

    After changing nginx config, you must reload nginx to apply changes.
  2. Step 2: Identify why no debug logs appear

    If nginx is not reloaded, it uses old config without debug logging.
  3. Final Answer:

    Nginx was not reloaded after config change -> Option B
  4. Quick Check:

    Reload nginx after config change [OK]
Hint: Reload nginx after config changes to activate debug [OK]
Common Mistakes:
  • Forgetting to reload nginx
  • Thinking debug disables logs
  • Misspelling debug level
5. You want to enable debug mode only temporarily to avoid large log files. Which is the best approach?
hard
A. Delete log files manually to reduce size
B. Permanently set debug mode in nginx.conf
C. Disable logging completely during debugging
D. Set error_log /var/log/nginx/error.log debug;, reload nginx, then revert after debugging

Solution

  1. Step 1: Understand temporary debug enabling

    Temporarily enable debug by changing error_log level and reloading nginx.
  2. Step 2: Revert changes after debugging

    To avoid large logs, revert error_log level back and reload nginx again.
  3. Final Answer:

    Set error_log /var/log/nginx/error.log debug;, reload nginx, then revert after debugging -> Option D
  4. Quick Check:

    Temporary debug = enable then revert [OK]
Hint: Enable debug, reload, then revert to avoid big logs [OK]
Common Mistakes:
  • Leaving debug mode enabled permanently
  • Deleting logs instead of controlling debug level
  • Disabling logging disables debug info