Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mLLBD-0005bZ-6g for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Sep 2021 08:01:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mLLBC-00016Z-5a for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Sep 2021 08:01:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mLLBB-00016N-St for pgsql-hackers@lists.postgresql.org; Wed, 01 Sep 2021 08:01:05 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mLLB5-0003V9-Nc for pgsql-hackers@lists.postgresql.org; Wed, 01 Sep 2021 08:01:04 +0000 Received: by mail-wr1-x42a.google.com with SMTP id x6so3015733wrv.13 for ; Wed, 01 Sep 2021 01:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aiven.io; s=google; h=from:to:subject:date:message-id:organization:in-reply-to:references :mime-version:content-transfer-encoding; bh=wpvf2uEmIFFBXC0222s951MzLPIx7+czHec2Wl4S5HY=; b=QAYDPeKW/yCSEAwF/KyC5/Gh0iacXjygM3JkjkQ96dbAu3kVB6pN2AFCEiA7JociLN avuOGZkn/7sOZ3k0i7lOvNK2M4Bc86nCgK0mBJsWG38vkxjrg6V2A6bMYCfhJI7TOASr bkSyCSaJ1fq2VB/Qr69HpNCHSnqcdnKbqiA5Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:organization :in-reply-to:references:mime-version:content-transfer-encoding; bh=wpvf2uEmIFFBXC0222s951MzLPIx7+czHec2Wl4S5HY=; b=U2699j3J0oSePyHhE1+Q+L1YEaHigyyUGe6YeEZ1sM96akROLT1q/tylKkzXizOmAo Eh9No5azWCsZg6E4Zt8WVPLRw/Ce53MAehAGYQ2r+8U7volyTyxNAOPkExgS8VNNU9uJ oeugOdNBsb/Gvo2fvcfOEkYWwMfqDu3IDMOQ0SuwhlNynqEXj0s/hUS5UqdvSIJMSkuH RUPvEW+GrV1joTL+JDIto8JBL/LGgsqEf16xCRX6SWt6h5y9S9L2b7hJQmV8HV59xqUg +6ovlPqna9r0HzhSWyKqb3+xHsC73AQDNk70NRh+ZBxEQrtr+QAGc05lxTDn2Juoo3MN EbfA== X-Gm-Message-State: AOAM532f16vFp0Z37Yb3Fx9P5q8eLB75V3Rid1j6Y1zloFlXyjnmssOz lkXgpjssdKq9TpfWdSf28xyr574D2fhzOQ== X-Google-Smtp-Source: ABdhPJyiuLc/2JGWnsalqcJAJ6GTuQcEulLZSuG8k504p97Iu7aSLM3qzsNohk3gyJCQox8cat8ylA== X-Received: by 2002:adf:f101:: with SMTP id r1mr35996443wro.355.1630483257093; Wed, 01 Sep 2021 01:00:57 -0700 (PDT) Received: from aivenronan.localnet (static-176-158-121-96.ftth.abo.bbox.fr. [176.158.121.96]) by smtp.gmail.com with ESMTPSA id o18sm15837380wrg.23.2021.09.01.01.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 01:00:56 -0700 (PDT) From: Ronan Dunklau To: pgsql-hackers@lists.postgresql.org, Peter Eisentraut Subject: Re: Proposal: More structured logging Date: Wed, 01 Sep 2021 10:00:28 +0200 Message-ID: <163276811.1OrvvjSa7g@aivenronan> Organization: aiven In-Reply-To: References: <3207907.AWbSqkKDnR@aivenronan> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Le mercredi 1 septembre 2021, 09:36:50 CEST Peter Eisentraut a =E9crit : > On 13.08.21 15:23, Ronan Dunklau wrote: > > The logging system already captures a lot of information in the ErrorDa= ta. > > But at present there is no way for a log message authors to include more > > metadata about the log outside of the log message itself. For example, > > including the extension name which can be useful for filtering / > > dispatching log messages. This can be done in the log message itself, b= ut > > that requires specialized parsing in the log output. > >=20 > > Even though among the available loggers in core, only the csv logger wo= uld > > be able to make sense of it, I feel it would be beneficial to add a > > tagging system to logs, by adding different (tag, value) combinations to > > a log entry, with an API similar to what we do for other ErrorData > > fields: > >=20 > > ereport(NOTICE, > >=20 > > (errmsg("My log message")), > > (errtag("EMITTER", "MYEXTENSION")), > > (errtag("MSG-ID", "%d", error_message_id)) > >=20 > > ); >=20 > What are some more examples of where this could be used? The extension > name could be added more or less automatically to ereport() calls. I > don't know what the MSG-ID is supposed to be. Are there other use cases? Adding it automatically would be nice, but how would you go about that ? In-core it would open up the possibility to split log messages into differe= nt=20 fields, for example the different statistics reported in the logs by VACUUM= /=20 ANALYZE VERBOSE and make it easier to consume the output without having to= =20 parse the message. Parsing the message also means that any tool parsing it= =20 needs to either be aware of the locale, or to force the user to use a speci= fic=20 one. Out-of-core, the same things could be done for extensions like pg_audit whi= ch=20 logs structured information into the message itself, leaving the message=20 format to be parsed at a later time. =2D-=20 Ronan Dunklau