Welcome! Log In Create A New Profile

Advanced

Re: how to use ngx_log_debug during configuration of a core module

Maxim Dounin
March 24, 2010 11:42AM
Hello!

On Wed, Mar 24, 2010 at 03:56:34PM +0100, Manlio Perillo wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Maxim Dounin ha scritto:
> > Hello!
> >
> > On Wed, Mar 24, 2010 at 03:04:00PM +0100, Manlio Perillo wrote:
> >
> >> I'm having some troubles at using ngx_log_debug during configuration of
> >> a core module I'm writing.
> >>
> >> I want to output some log info in the init_conf callback function but:
> >>
> >> * If I use cycle->log, the error level is fixed and set to NGX_LOG_INFO,
> >> so debug info will never be logged
> >> * If I use cycle->new_log, the error level is correctly set, but no info
> >> is logged to the file.
> >> If I set log destination to "stderr", info is correctly logged
> >>
> >>
> >> Should I simply use ngx_log_error(NGX_LOG_INFO, cycle->log)?
> >
> > Yes.
> >
>
> Tried rigth now, and it does not work.
>
> I have logged the log name and fd of cycle->log, and I have:
> log->name: (null), log->fd: 3
>
> The cycle->new_log, instead, have:
> log->name: /usr/local/nginx/logs/error.log, log->fd: -1
>
>
> It seems that the log object is not fully configured, when module init
> callbacks are called.

I've just tested and looked through code - module init callbacks
(init_module member of ngx_module_t structure) are called after
full configuration has been initialized (including logs) and even
debug works perfectly using cycle->log (once you have error_log
.... debug; configured at top level).

>From data you provide it looks like you in fact use create_conf
or init_conf callbacks of ngx_core_module_t structure.

You still should be able to use ngx_log_error(cycle->log), though
level is initialized to NGX_LOG_NOTICE by default (so it's minimum
level which will be logged unless you are reconfiguring already
running nginx).

Maxim Dounin

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

how to use ngx_log_debug during configuration of a core module

Manlio Perillo 4944 March 24, 2010 10:06AM

Re: how to use ngx_log_debug during configuration of a core module

Maxim Dounin 1396 March 24, 2010 10:42AM

Re: how to use ngx_log_debug during configuration of a core module

Manlio Perillo 1348 March 24, 2010 10:58AM

Re: how to use ngx_log_debug during configuration of a core module

Maxim Dounin 1401 March 24, 2010 11:42AM

Re: how to use ngx_log_debug during configuration of a core module

Manlio Perillo 1568 March 24, 2010 12:48PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 287
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready