1

How to log in nginx module request handler?

Kindly point to the docs if its already presented elsewhere.

For now:

static ngx_int_t ngx_http_printer_hander(ngx_http_request_t* r) {

    // ...
    ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, "Hello LOG!");
    // ...

I picked this up from the source code. And this works. But this always logs to error.log.

  • I'm looking for ways to log to specific log file.
  • Some information about creating a custom log object is appreciated.

Thanks,

1 Answer 1

1

Simple hacking around, I found this works:

fprintf(stderr, "HELLO_WORLD\n");
  • But still printing to error.log.
  • Still looking for ways to print to custom log file.
  • Unsure about the consequence of adding logs that prints directly to files. I guess this should also be part of the event loop of worker.

Perhaps someone could shed some light on this.

Thanks,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.