Thread: How to Output PSQL Errors to a Log File?

How to Output PSQL Errors to a Log File?

From
"Wang, Mary Y"
Date:
Hi,

I used 'pg_dumpall' to dump the database in Postgres 7.1.3 and I'm in the process of restoring the databases in
Postgres8.3.8.  There were lots errors showed on the screen when I ran this command 'psql -e template1 -f 21.bak' and
itactually displayed the line numbers where the errors occurred.  Because there were so many errors, and I wanted the
errorsto be logged to a log file so I ran this command 'psql -e template1 -f 21.bak > late22error.txt', but
late22error.txtdidn't log the errors, it just logged the transactions.  What option should I use to tell psql to log
allerrors to a log file? 

I'm running on RHEL 3.9.

Thanks
Mary




Re: How to Output PSQL Errors to a Log File?

From
"Joshua D. Drake"
Date:
On Mon, 22 Feb 2010 23:19:34 -0800, "Wang, Mary Y"
<mary.y.wang@boeing.com>
wrote:
> Hi,
>
> I used 'pg_dumpall' to dump the database in Postgres 7.1.3 and I'm in
the
> process of restoring the databases in Postgres 8.3.8.  There were lots
> errors showed on the screen when I ran this command 'psql -e template1
-f
> 21.bak' and it actually displayed the line numbers where the errors
> occurred.  Because there were so many errors, and I wanted the errors to
be
> logged to a log file so I ran this command 'psql -e template1 -f 21.bak
>
> late22error.txt', but late22error.txt didn't log the errors, it just
logged
> the transactions.  What option should I use to tell psql to log all
errors
> to a log file?
>
> I'm running on RHEL 3.9.

Wow that takes us back aways. Did you dump the 7.1 with the 8.3 version of
pg_dump? That should help.

>
> Thanks
> Mary

--
PostgreSQL - XMPP: jdrake(at)jabber(dot)postgresql(dot)org
   Consulting, Development, Support, Training
   503-667-4564 - http://www.commandprompt.com/
   The PostgreSQL Company, serving since 1997

Re: How to Output PSQL Errors to a Log File?

From
John R Pierce
Date:
Wang, Mary Y wrote:
> Hi,
>
> I used 'pg_dumpall' to dump the database in Postgres 7.1.3 and I'm in the process of restoring the databases in
Postgres8.3.8.  There were lots errors showed on the screen when I ran this command 'psql -e template1 -f 21.bak' and
itactually displayed the line numbers where the errors occurred.  Because there were so many errors, and I wanted the
errorsto be logged to a log file so I ran this command 'psql -e template1 -f 21.bak > late22error.txt', but
late22error.txtdidn't log the errors, it just logged the transactions.  What option should I use to tell psql to log
allerrors to a log file? 
>
> I'm running on RHEL 3.9.
>
>
>
you need to redirect stderr, see
http://www.cyberciti.biz/faq/redirecting-stderr-to-stdout/  for a
variety of options





Re: How to Output PSQL Errors to a Log File?

From
Nilesh Govindarajan
Date:
On 02/23/2010 12:54 PM, Nilesh Govindarajan wrote:
> On 02/23/2010 12:49 PM, Wang, Mary Y wrote:
>> Hi,
>>
>> I used 'pg_dumpall' to dump the database in Postgres 7.1.3 and I'm in
>> the process of restoring the databases in Postgres 8.3.8. There were
>> lots errors showed on the screen when I ran this command 'psql -e
>> template1 -f 21.bak' and it actually displayed the line numbers where
>> the errors occurred. Because there were so many errors, and I wanted
>> the errors to be logged to a log file so I ran this command 'psql -e
>> template1 -f 21.bak> late22error.txt', but late22error.txt didn't log
>> the errors, it just logged the transactions. What option should I use
>> to tell psql to log all errors to a log file?
>>
>> I'm running on RHEL 3.9.
>>
>> Thanks
>> Mary
>>
>>
>>
>>
>
> psql <...your options...> 2> errorfile.txt
>
> This is the general shell error redirection. This will work if psql
> outputs errors to stderr and not stdout. (Try it out ;))
>


--
Nilesh Govindarajan
Site & Server Adminstrator
www.itech7.com

Re: How to Output PSQL Errors to a Log File?

From
"Wang, Mary Y"
Date:
No. I dumped the 7.1 with the 7.1 version of pg_dump.
Is it better to dump with the 8.3 version of pg_dump?  I thought I read it some where in the mailing lists.  I don't
knowhow I would be able to dump with the 8.3 version of pg_dump.  The database and Postgres 7.1 is loaded on the
currentproduction box and Postgres 8.3.8 is loaded on a dev server that I plan to migrate the database to. 

Please advise.
Mary

-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Joshua D. Drake
Sent: Monday, February 22, 2010 11:25 PM
To: Wang, Mary Y
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] How to Output PSQL Errors to a Log File?

On Mon, 22 Feb 2010 23:19:34 -0800, "Wang, Mary Y"
<mary.y.wang@boeing.com>
wrote:
> Hi,
>
> I used 'pg_dumpall' to dump the database in Postgres 7.1.3 and I'm in
the
> process of restoring the databases in Postgres 8.3.8.  There were lots
> errors showed on the screen when I ran this command 'psql -e template1
-f
> 21.bak' and it actually displayed the line numbers where the errors
> occurred.  Because there were so many errors, and I wanted the errors
> to
be
> logged to a log file so I ran this command 'psql -e template1 -f
> 21.bak
>
> late22error.txt', but late22error.txt didn't log the errors, it just
logged
> the transactions.  What option should I use to tell psql to log all
errors
> to a log file?
>
> I'm running on RHEL 3.9.

Wow that takes us back aways. Did you dump the 7.1 with the 8.3 version of pg_dump? That should help.

>
> Thanks
> Mary

--
PostgreSQL - XMPP: jdrake(at)jabber(dot)postgresql(dot)org
   Consulting, Development, Support, Training
   503-667-4564 - http://www.commandprompt.com/
   The PostgreSQL Company, serving since 1997

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: How to Output PSQL Errors to a Log File?

From
Devrim GÜNDÜZ
Date:
On Mon, 2010-02-22 at 23:32 -0800, Wang, Mary Y wrote:
> No. I dumped the 7.1 with the 7.1 version of pg_dump.
> Is it better to dump with the 8.3 version of pg_dump?

Since you will be restoring your data to a 8.3 server, you should use
8.3 pg_dump, yes.

>  I thought I read it some where in the mailing lists.  I don't know
> how I would be able to dump with the 8.3 version of pg_dump.  The
> database and Postgres 7.1 is loaded on the current production box and
> Postgres 8.3.8 is loaded on a dev server that I plan to migrate the
> database to.

After setting tcpip_socket to true and granting access using
pg_hba.conf, you can connect from 8.3 machine to 7.1 machine (you may
need to change your firewall settings, etc), like:

pg_dump -h ip/hostname/of/7.1/machine dbname -f dump.file

You don't need to compile and install 8.3 to 7.1 machine.
--
Devrim GÜNDÜZ, RHCE
PostgreSQL Danışmanı/Consultant, Red Hat Certified Engineer
devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.gunduz.org  Twitter: http://twitter.com/devrimgunduz

Attachment

Re: How to Output PSQL Errors to a Log File?

From
"Wang, Mary Y"
Date:
Cool!  That worked.  Thanks.  Now I just have to see if I can migrate the database data from 7.1 to 8.3 successfully.
Mary

-----Original Message-----
From: Devrim GÜNDÜZ [mailto:devrim@gunduz.org]
Sent: Monday, February 22, 2010 11:43 PM
To: Wang, Mary Y
Cc: Joshua D. Drake; pgsql-general@postgresql.org
Subject: Re: [GENERAL] How to Output PSQL Errors to a Log File?

On Mon, 2010-02-22 at 23:32 -0800, Wang, Mary Y wrote:
> No. I dumped the 7.1 with the 7.1 version of pg_dump.
> Is it better to dump with the 8.3 version of pg_dump?

Since you will be restoring your data to a 8.3 server, you should use
8.3 pg_dump, yes.

>  I thought I read it some where in the mailing lists.  I don't know
> how I would be able to dump with the 8.3 version of pg_dump.  The
> database and Postgres 7.1 is loaded on the current production box and
> Postgres 8.3.8 is loaded on a dev server that I plan to migrate the
> database to.

After setting tcpip_socket to true and granting access using pg_hba.conf, you can connect from 8.3 machine to 7.1
machine(you may need to change your firewall settings, etc), like: 

pg_dump -h ip/hostname/of/7.1/machine dbname -f dump.file

You don't need to compile and install 8.3 to 7.1 machine.
--
Devrim GÜNDÜZ, RHCE
PostgreSQL Danışmanı/Consultant, Red Hat Certified Engineer devrim~gunduz.org, devrim~PostgreSQL.org,
devrim.gunduz~linux.org.trhttp://www.gunduz.org  Twitter: http://twitter.com/devrimgunduz