Re: Logging ALL output from psql

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Bobby Dewitt <Bdewitt(at)appriss(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Logging ALL output from psql
Date: 2011-10-19 21:15:49
Message-ID: 4E9F3E05.1090206@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 19/10/2011 22:10, Bobby Dewitt wrote:
> I can not find a way to log ALL output from a psql session when running
> a script. Basically, I'm running a large deployment script that has
> thousands of SQL statements and I need to know which statements fail. I
> want the output generated when running the script to be saved to a log
> file so that I can grep through the output and look for errors. I don't
> want the script to stop processing using the ON_ERROR_STOP variable. It
> doesn't matter to me if the script is run interactively or not.
>
> I've tried redirecting the output to a log file, but this only gets the
> SQL statements issued and their results and not the errors that may be
> encountered:
> psql -f test_psql_deployment_logging.sql > test_psql_deployment_logging.log
>

You need to redirect stderr as well - add "2>&1" to the end of the command.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adam Cornett 2011-10-19 22:50:30 Re: Date Range Using Months and Days Only
Previous Message Bobby Dewitt 2011-10-19 21:10:13 Logging ALL output from psql