[英]Log levels in Nginx: NGX_LOG_DEBUG_HTTP vs NGX_LOG_DEBUG
I am inspecting some Nginx code, in particular the code for Nginx module - upstream health check .我正在检查一些 Nginx 代码,特别是Nginx 模块的代码 - 上游健康检查。 At some places I see
NGX_LOG_DEBUG_HTTP
as the logging level, at others NGX_LOG_DEBUG
.在某些地方我看到
NGX_LOG_DEBUG_HTTP
作为日志记录级别,在其他NGX_LOG_DEBUG
。 Could someone tell me which logging level is recommended to be used in which scenario?有人可以告诉我建议在哪种情况下使用哪种日志记录级别?
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
如果您的
nginx.conf
的日志级别定义为通用debug
error_log error.log debug;
then all your logging statments with debug levels prefixed with NGX_LOG_DEBUG
will be logged.然后将记录所有带有前缀为
NGX_LOG_DEBUG
的调试级别的日志记录语句。 For eg例如
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.但是,如果您的
nginx.conf
配置为记录特定类型的调试消息,则只会记录那些。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.