Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gABo7-0008A3-1g for pgsql-general@arkaria.postgresql.org; Wed, 10 Oct 2018 10:33:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gABo5-0008NC-3x for pgsql-general@arkaria.postgresql.org; Wed, 10 Oct 2018 10:33:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gABo4-0008Mo-Dl for pgsql-general@lists.postgresql.org; Wed, 10 Oct 2018 10:33:32 +0000 Received: from mail.wordtothewise.com ([104.225.223.158]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gABo0-00015k-Vp for pgsql-general@postgresql.org; Wed, 10 Oct 2018 10:33:30 +0000 Received: from [192.168.0.88] (unknown [37.228.229.189]) by mail.wordtothewise.com (Postfix) with ESMTPSA id BD039A0860 for ; Wed, 10 Oct 2018 03:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wordtothewise.com; s=aardvark; t=1539167608; bh=mKhrTlZuRqO/BxwGipHj6ZjIL81WS920PvK83QnlJ78=; h=From:Subject:Date:References:To:In-Reply-To:From; b=O4XEQG6wIu7Pkc/c/V96lGqaMzKSLSA3p+zD1RT+Irr4rxPTAFUAREJHnAmxcXwzB ySs89BwBmqxJA9jXu5UtRZy/c5sMdyevV5OCYNfvzdaL3lS0nUtzpP10XNWXwnj660 nbj+CfAEs3abgJ5dRn9t/Amqs6vN5OQYf0mO9Kgc= From: Steve Atkins Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: Pg_logical without subscription. Can we log the operations ? Date: Wed, 10 Oct 2018 11:33:25 +0100 References: To: PG-General Mailing List In-Reply-To: Message-Id: <6DF0FBD0-EDFC-45DF-A9E6-A744CC985B3B@blighty.com> X-Mailer: Apple Mail (2.3273) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Oct 9, 2018, at 11:45 PM, Dilshan wrote: >=20 > Hi Team, > I am working on a requirement, where I need to log each and every = operation on the master db. So I was thinking if I could do with = pg_logical by setting my master db as publisher and setting a new db as = subscriber and dropping the subscription there after. I am wondering, = how to get the operations that a subscription would receive just into = logs. Could you guide me on that? Otherwise is there a possibility to = receive all the operation without dropping subscription and logging the = details and deleting the subscription tables to save space. I am = planning to have logs rotated and purging logs every month. Could you = please guide me about the possibility of this approach? You can read the logical replication stream with clients other than = postgresql, and you can use plugins to format it in different ways. https://wiki.postgresql.org/wiki/Logical_Decoding_Plugins has some of = the third-party plugins to format the changes. There are libraries for most languages to consume the logical decoding = stream, or the included client "pg_recvlogical" can be used to write it = to disk. pg_recvlogical + wal2json might be the simplest way to do a basic audit = trail. Cheers, Steve=