Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: add guide on enabling pgaudit

Div Arorad7a959145f09
diff --git a/apps/reference/docs/guides/platform/logs.mdx b/apps/reference/docs/guides/platform/logs.mdx
index bcc2173f994..6810cce4433 100644
--- a/apps/reference/docs/guides/platform/logs.mdx
+++ b/apps/reference/docs/guides/platform/logs.mdx
@@ -34,7 +34,32 @@ To update the screenshots, ensure that at least one log line is selected to disp
</TabItem>
<TabItem value="postgres" label="Postgres">
-[Postgres logs](https://app.supabase.com/project/_/database/postgres-logs) show all queries and activity for your [database](../../guides/database).
+[Postgres logs](https://app.supabase.com/project/_/database/postgres-logs) show queries and activity for your [database](../../guides/database).
+
+By default, query logs are disabled for all new Supabase projects, as they can reveal metadata about the contents of your database (e.g. table and column names). If you'd like to enable query logs, you can enable and configure the [pgAudit extension](https://www.pgaudit.org/):
+
+- [Enable the pgAudit extension for your project](https://app.supabase.com/project/_/database/extensions)
+- [Reboot the DB](https://app.supabase.com/project/_/settings/general); a "Fast database reboot" is sufficient, and faster than a full project restart
+- Configure `pgaudit.log` to the [appropriate value](https://github.com/pgaudit/pgaudit/blob/master/README.md#pgauditlog)
+- You should be able to view query logs in your [log explorer](https://app.supabase.com/project/_/database/postgres-logs) now
+
+As an example, if you wanted to enable logs for writes and DDL statements for a single session, you could execute within the session:
+
+```sql
+set pgaudit.log = 'write, ddl';
+```
+
+To _permanently_ enable logs for all statements that relate to roles and privileges, you could execute (followed by a db reboot):
+
+```sql
+alter system set pgaudit.log to 'role';
+```
+
+To remove a system-wide setting, you can use (followed by a db reboot):
+
+```sql
+alter system reset pgaudit.log
+```
![Postgres Logs](/img/guides/platform/logs/logs-database.png)