0

The default postgresql.conf file created using initdb contains the following line

#logging_collector = off  # Enable capturing of stderr and csvlog

Is there anyway to force initdb itself to generate a file with

logging_collector = on

rather than set options on pg-ctl or edit the generated file.

mark d drake
  • 1,280
  • 12
  • 20

2 Answers2

1

I keep all the changes in a separate file named custom.conf

Then after initdb ran, I copy the file to the data directory and append an include directive to postgresql.conf:

cp /path/to/dir/custom.conf $PGDATA
echo include = 'custom.conf' >> $PGDATA/postgresql.conf

These steps are easily scriptable, so no manual intervention required.

Alternatively you can skip the copy step and include the config file directly from the central directory. Or you could use include_dir to include the whole directory where your custom config file is stored.

This has the added benefit (in my opinion) that I have all customizations in a single file. I don't need to go through postgresql.conf to find settings that are changed from the default.

0

No, there is no way to do it like that.

But you can modify the file postgresql.conf.sample in the “share” directory of the PostgreSQL installation, which is used as the blueprint for postgresql.conf during initdb.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • Damn, and the Thanks. Unfortunately modifying the template has the same challanges as modifying the file itself. I am creating a windows container, so I download the Installation media as part of myDockerfile, so I don't win anything by modifying the file before I invoke initdb. – mark d drake Nov 19 '21 at 06:41
  • You can certainly modify an installed file in your dockerfile, right? – Laurenz Albe Nov 19 '21 at 06:47