Here is the problem: I need to know how to get all PostgreSQL output from an executed .sql script to log to a file, including errors and query results.
I have already surrounded my script with \o and \o opening and closing tags, but this only logs the results of queries, which tells me nothing about what did and did not succeed. I have tried piping the results of a call to to PostgreSQL using Unix tools like so:
$~: psql < filename.sql | tee &> filename.log
... with no success. Filename.log in this case ends up completely empty.
I don't want to activate universal logging, as I am only concerned with the success/failure of the scripts I have written and keeping a record of this for future reference.
In Oracle, I used SPOOL, in MySQL I used TEE. Both of these worked well enough for my needs, but \o does not have this functionality, and neither does activating logging, as this logs to a single file and I want my logs separated based on which file resulted in those logs.
Any help would be appreciated.
EDIT: the version I am using is 9.1
EDIT: The problem I am having is that using -f and using < to execute .sql files gives me essentially the same results; it doesn't log the errors, it only logs query results. I need to somehow get stderr (if that's what is used) to print it's messages to a file and not just the command line such that the file will essentially look identical to the command line results of running the file, with query results and errors mixed in. The reason I need to do this is because it makes debugging a .sql file much easier and it allows me to keep targeted records while avoiding universal error logging.