nginx error_log 日誌配置

來源:互聯網
上載者:User
關於 error_log 指令的解析


---- nginx-1.0.9 ---

error_log 配置:
error_log logs/xxx.log error | debug_core | debug_alloc

main(){    //...    prefix = ./configure --prefix    ngx_init_cycle(ngx_cycle_t *old_cycle)    {        log.log_level = NGX_LOG_NOTICE;        log = ngx_log_init() = $prefix + NGX_ERROR_LOG_PATH  = $prefix/logs/error.log;        ngx_conf_param(ngx_conf_t *cf)        {            ngx_error_log()            {                cycle->new_log = $conf_prefix/logs/xxx.log 或者 $prefix/logs/xxx.log;                ngx_log_set_levels()                {                    value = cf->args->elts;                    /* 從這段代碼上看:                        error_log 指令的記錄層級配置分為 錯誤記錄檔層級和調試記錄層級                       且 錯誤記錄檔只能設定一個層級 且 錯誤記錄檔必須書寫在調試記錄層級的前面 且 調試日誌可以設定多個層級                       其他配置方法可能達不到你的預期.                     */                    for (i = 2; i < cf->args->nelts; i++) {                        found = 0;                        for (n = 1; n <= NGX_LOG_DEBUG; n++) {                            if (ngx_strcmp(value[i].data, err_levels[n].data) == 0) { /* 這裡匹配的是 錯誤記錄檔層級 */                                log->log_level = n;                                found = 1;                                break;                            }                        }                        for (n = 0, d = NGX_LOG_DEBUG_FIRST; d <= NGX_LOG_DEBUG_LAST; d <<= 1) { /* 這裡匹配的是 調試記錄層級 */                            if (ngx_strcmp(value[i].data, debug_levels[n++]) == 0) {                                log->log_level |= d;                                found = 1;                                break;                            }                        }                    }                    if (log->log_level == NGX_LOG_DEBUG) {                        log->log_level = NGX_LOG_DEBUG_ALL;                    }                    return NGX_CONF_OK;                }            }        }        cycle->log = &cycle->new_log;        pool->log = &cycle->new_log;    }    //...}



-----------
總結
文法:
error_log file [ debug | info | notice | warn | error | crit ]  | [{  debug_core | debug_alloc | debug_mutex | debug_event | debug_http | debug_mail | debug_mysql } ]
記錄層級 = 錯誤記錄檔層級 | 調試記錄層級; 或者
記錄層級 = 錯誤記錄檔層級;
錯誤記錄檔的層級: emerg, alert, crit, error, warn, notic, info, debug, 
調試日誌的層級: debug_core, debug_alloc, debug_mutex, debug_event, debug_http, debug_mail, debug_mysql,


error_log 指令的記錄層級配置分為 錯誤記錄檔層級和調試記錄層級
且 錯誤記錄檔只能設定一個層級 且 錯誤記錄檔必須書寫在調試記錄層級的前面 且 調試日誌可以設定多個層級
其他配置方法可能達不到你的預期.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.