All the preceding functions are designed to run in a single process/backend as if the other PostgreSQL processes did not exist.
But what if you want to log something to a single file from multiple backends?
Seems easy—just open the file and write what you want. Unfortunately, it is not that easy if you want to do it from multiple parallel processes and you do not overwrite or mix up the data with what other processes write.
To have more control over the writing order between backends, you need to have some kind of inter-process synchronization, and the easiest way to do this in PostgreSQL is to use shared memory and light-weight locks (
To allocate its own shared memory segment your
.so file needs to be pre-loaded, ...