how can I divide log files for specific DB queries?
There is only a single PostgreSQL log file per database cluster, so you cannot have that out of the box.

Adding triggers that log to a file is an option, but a trigger (and the logging itself) can add significant performance overhead, certainly more than the PostgreSQL logging itself.

The route I would explore is this:


Try to perform the actions you want to log with a different database user. If that is not easy, be creative: perhaps you can execute SET ROLE/RESET ROLE commands at strategic points in debug mode to become a different user.
Enable logging for that user only:

ALTER ROLE myuser SET log_min_duration_statement = 0;



Then it will be easier to evaluate the log, because it will be smaller.