Log levels in Nginx: NGX_LOG_DEBUG_HTTP vs NGX_LOG_DEBUG

Viewed 526

I am inspecting some Nginx code, in particular the code for Nginx module - upstream health check. At some places I see NGX_LOG_DEBUG_HTTP as the logging level, at others NGX_LOG_DEBUG. Could someone tell me which logging level is recommended to be used in which scenario?

1 Answers

This link has the required information. Here are few scenarios to explain how it works:

If your nginx.conf has log level defined as the generic debug

error_log error.log debug;

then all your logging statments with debug levels prefixed with NGX_LOG_DEBUG will be logged. For e.g.

ngx_log_debug(NGX_LOG_DEBUG, event->log, 0, "test"); ngx_log_debug(NGX_LOG_DEBUG_HTTP, event->log, 0, "test"); ngx_log_debug(NGX_LOG_DEBUG_CORE, event->log, 0, "test");

But if your nginx.conf is configured to log a specific kind of debug message, only those will be logged.

So, with this config:

error_log error.log debug_http;

this will happen:

ngx_log_debug(NGX_LOG_DEBUG_CORE, event->log, 0, "test"); //will not show up in the log
ngx_log_debug(NGX_LOG_DEBUG_HTTP, event->log, 0, "test"); //will show up in the log
Related