In PostgreSQL, audit logging can be done using triggers. When a row is inserted into a table, a trigger can fire after the insert event. This trigger runs a function that inserts a record into an audit table, capturing details like the new row's id, data, and the current timestamp. The trigger function must return NEW to allow the insert to complete. If the audit insert fails, the entire transaction rolls back, ensuring data consistency. The execution table shows each step: insert event, trigger firing, audit insert, and completion. Variables like NEW.id and NEW.data hold the new row's values during trigger execution. This method helps track changes automatically and reliably.