Re: Unfiltered server logs routing via a new elog hook or existing emit_log_hook bypassing log_min_message check

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Unfiltered server logs routing via a new elog hook or existing emit_log_hook bypassing log_min_message check
Date: 2022-05-02 13:54:04
Message-ID: CALj2ACWRnaJabexR646R6815tRgrM8u8yzox9faCHy5iK82QcA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, May 2, 2022 at 6:44 PM Julien Rouhaud <rjuju123(at)gmail(dot)com> wrote:
>
> On Mon, May 02, 2022 at 06:40:05PM +0530, Bharath Rupireddy wrote:
> > On Mon, May 2, 2022 at 6:32 PM Julien Rouhaud <rjuju123(at)gmail(dot)com> wrote:
> > >
> > > Unless I'm missing something you can already do all of that with the current
> > > hook, since as mentioned in the comment above the hook can disable the server's
> > > logging:
> > >
> > > * Call hook before sending message to log. The hook function is allowed
> > > * to turn off edata->output_to_server, so we must recheck that afterward.
> > >
> > > So you can configure your server with a very verbose log_min_message, and have
> > > the same setting in your own extension to disable output_to_server after its
> > > own processing is done.
> >
> > No. The emit_log_hook isn't called for all the log messages, but only
> > when output_to_server = true which means, say my log_min_messages is
> > 'WARNING', the hook isn't called for the messages say elevel above it
> > (NOTICE, INFO, DEBUGX).
>
> I know. What I said you could do is configure log_min_message to DEBUGX, so
> your extension sees everything you want it to see. And *in your extension* set
> output_to_server to false if the level is not the *real level* you want to log.

I basically want to avoid normal users/developers setting any
parameter (especially the superuser-only log_min_message GUC, all
users might not have superuser access in production environments) or
making any changes to the running server except just LOADing the
server log routing/intercepting extension.

Regards,
Bharath Rupireddy.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2022-05-02 13:57:45 Re: limiting collected query text length in pg_stat_statements
Previous Message David Christensen 2022-05-02 13:42:13 Re: [PATCH] Teach pg_waldump to extract FPIs from the WAL