How exactly does PostgreSQL expect me to read in/delete the CSV log files?


I’ve been following the (very sparse and cryptic) instructions here: https://www.postgresql.org/docs/12/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG

  1. I’ve set up the postgres_log table exactly like it says on that page.

  2. I’ve set up my postgresql.conf like this:

    log_destination = ‘csvlog’

    logging_collector = on

    log_directory = ‘C:\pglogs’

    log_filename = ‘PG_%Y-%m-%d_%H;%M;%S’

    log_rotation_age = 1d

    log_rotation_size = 0

    log_truncate_on_rotation = on

  3. I’ve restarted PostgreSQL, and it has created a PG_2020-09-20_00;56;19.csv and PG_2020-09-20_00;56;19 file.

  4. I am able to successfully run a COPY query to import the PG_2020-09-20_00;56;19.csv into my database table, if I explicitly name it.

My problems:

  1. How am I supposed to determine which filename(s) to pick to COPY into the table from my automated, regularly run script? (Since it can’t be the "current" one.)
  2. After I have somehow determined which filename(s) are safe to COPY in, and I’ve loaded them into my table, am I expected to delete these myself?
  3. What’s with the plaintext-format PG_2020-09-20_00;56;19 file? Why is that created when I clearly tell PG to use CSV?

None of this is addressed on the page I linked to and which I’ve been following.