Check out the "log_statement" option in the postgresql.conf file(there's an entire section (18.7) in the docs about logging).