# pgaudit — Postgres extension

> Write detailed audit lines for the statements you choose.

Source: https://scribase.com/extensions/pgaudit

Category: Security and secrets. Version: 17.1. Optional, enabled per project.

## About

pgaudit writes structured audit records to the database log for the classes of statements you pick (read, write, ddl, role, function). Standard statement logging records text; pgaudit records which objects a statement touched, which is what compliance reviews usually ask for.

## Enable it

```sql
create extension if not exists pgaudit with schema extensions;
```

## Example

```sql
-- audit every write and schema change made through the API roles
alter role authenticated set pgaudit.log = 'write, ddl';

-- or only one table: object auditing through a dedicated role
create role auditor nologin;
grant select, update on payments to auditor;
alter role authenticated set pgaudit.role = 'auditor';
```

Upstream: https://github.com/pgaudit/pgaudit