Как правильно писать логи из функции-обработчика запросов?
    Sergey S. 
    neavirc at gmail.com
       
    Tue Mar 11 18:05:00 MSK 2008
    
    
  
Здравствуйте.
Написал простенький handler, но почему-то не получается писать из него логи
с помощью ngx_log_error. nginx запускается с директивой "daemon off"; в
других местах (например в ngx_http_test_merge_loc_conf) ngx_log_error
работает как надо.
Делал так. Когда встречается директива "mytest":
static ngx_command_t  ngx_http_test_commands[] = {
    // Install
http-handler
    { ngx_string("mytest"),
      NGX_HTTP_MAIN_CONF|NGX_CONF_NOARGS,
      ngx_http_test_install_handler, // <<---------------------------------
      NGX_HTTP_LOC_CONF_OFFSET,
      0,
      NULL },
// ...
      ngx_null_command
}
Запускается установщик обработчика:
static char* ngx_http_test_install_handler(ngx_conf_t *cf, ngx_command_t
*cmd, void *conf)
{
  ngx_http_core_loc_conf_t* clcf =
static_cast<ngx_http_core_loc_conf_t*>(ngx_http_conf_get_module_loc_conf(cf,
ngx_http_core_module));
  clcf->handler = ngx_http_test_handler;
  return NGX_CONF_OK;
}
Сам же обработчик выгладит очень просто:
static ngx_int_t ngx_http_test_handler(ngx_http_request_t *r)
{
  ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "test"); // Это
сообщение никогда не отображается
  return NGX_OK;
}
Я где-то ошибся? Пробовал устанавливать обработчик через ngx_http_test_init
- не помогло.
--
С уважением,
Сергей Самохин.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx-ru/attachments/20080311/0d22a956/attachment.html>
    
    
More information about the nginx-ru
mailing list