Обсуждение: Redirect ERROR, FATAL and other messages

Поиск
Список
Период
Сортировка

Redirect ERROR, FATAL and other messages

От
pittgs
Дата:
Hello!

I'm executing a postgres command from a C code, the command that I introduce
is the following:

"sudo -u pgsql psql -p 3306 -d triage_dump -c 'insert into control select
*from uuid ' > logfile"

In the logfile, the output is introduced, but certain lines are not, like
for example:
*ERROR:  duplicate key value violates unique constraint "control_pkey"
DETAIL:  Key (uuid)=(10000717) already exists.
could not find a "psql" to execute*

I understand the error messages, but I don't want them to appear in the
screen (stdout), is there any way to send this messages to a log file? I
need all messages from postgres goes to a logfile, but seems is not enough
with "> logfile"
Can somebody give me a hint to solve my issue?

Thanks in advance
Gabs

--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Redirect-ERROR-FATAL-and-other-messages-tp5154551p5154551.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Re: Redirect ERROR, FATAL and other messages

От
Jerry Sievers
Дата:
pittgs <gabriela.pittari@triagnosys.com> writes:

> Hello!
>
> I'm executing a postgres command from a C code, the command that I introduce
> is the following:
>
> "sudo -u pgsql psql -p 3306 -d triage_dump -c 'insert into control select
> *from uuid ' > logfile"
>
> In the logfile, the output is introduced, but certain lines are not, like
> for example:
> *ERROR:  duplicate key value violates unique constraint "control_pkey"
> DETAIL:  Key (uuid)=(10000717) already exists.
> could not find a "psql" to execute*
>
> I understand the error messages, but I don't want them to appear in the
> screen (stdout), is there any way to send this messages to a log file? I
> need all messages from postgres goes to a logfile, but seems is not enough
> with "> logfile"
> Can somebody give me a hint to solve my issue?

See the 2 settings;

client_min_messages
log_min_messages

> Thanks in advance
> Gabs
>
> --
> View this message in context:
http://postgresql.1045698.n5.nabble.com/Redirect-ERROR-FATAL-and-other-messages-tp5154551p5154551.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres.consulting@comcast.net
p: 305.321.1144

Re: Redirect ERROR, FATAL and other messages

От
hubert depesz lubaczewski
Дата:
On Wed, Jan 18, 2012 at 03:20:05AM -0800, pittgs wrote:
> with "> logfile"
> Can somebody give me a hint to solve my issue?

errors are written not to stdout (which is redirected with >), but to
stderr.
which means, that you can redirect them, as with any other program, with
2>, like:

psql ... > logfile 2>&1

depesz

--
The best thing about modern society is how easy it is to avoid contact with it.
                                                             http://depesz.com/