Put these lines into
postgresql.conf to log the queries and their execution time if they run for longer than 500ms:
to find the slowest queries. Then pick the session ids (this is the first part of the prefix of each line) you are interested in and
grep for those.
The log files accumulate due to %F being part of
log_filename and the log files become large rather quickly due to
log_statement being set to
all, so keep an eye on the size of the log files and delete them, either manually, or automatically in a cron job to avoid filling up your disk.
log_directory require a server restart. To activate any of the other parameters, a reload like
pg_ctl reload is sufficient. So you can switch on
log_min_duration_statement only when needed and then switch it off again to control log size growth.