One of the important security features of PostgreSQL is to perform logging of a certain activity. When a certain modification is done to a Postgres table or when a table has been dropped, it is important to know whether that was intended to be a requirement or was performed illegally by misusing the access to the database. In this recipe, we shall discuss the steps required to log certain types of activity required for auditing in PostgreSQL.
Getting ready
It is always important to know that logging additional information to PostgreSQL logs causes more disk writes and uses a lot of disk space. For this reason, it is important to monitor the disk usage and the IOPS increase when any extensive logging has been enabled. It is also important to segregate logs and data across different disks. This way, none of the logging-specific writes cause any I/O saturation for a data directory that contains database objects.
How to do it...
We will log data using the...