How to write to Nginx access log from custom module

92 views Asked by At

I'm writing a custom Nginx module (in C++). I am able to add any message to Nginx' error log without any issues, like:

std::cerr << "some content";

I do not know how to add something to Nginx' access log. I tried functions like ngx_log_debug0 but without success:

ngx_log_debug0(NGX_LOG_INFO, log, 0, "some content");

I tried this in two contexts:

  1. I have a postconfiguration function with ngx_conf_t *cf as a parameter from where I take log variable used above (as a second parameter):

    cf->log

  2. I have a function which handles http requests as a command which has interface: ngx_int_t my_function(ngx_http_request_t *r); from where also tried to use log but also without success: r->connection->log

Do I need to setup smth? Everything else works fine. Perhaps it is not possible to add custom messages to original access log?

0

There are 0 answers