pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedlogging SQL statements
4+ messages / 4 participants
[nested] [flat]
* logging SQL statements
@ 2008-10-09 13:23 c k <shreeseva.learning@gmail.com>
2008-10-09 20:40 ` Re: logging SQL statements Greg Smith <gsmith@gregsmith.com>
2008-10-10 07:57 ` Re: logging SQL statements Jagadeesh <mnjagadeesh@gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: c k @ 2008-10-09 13:23 UTC (permalink / raw)
To: pgsql-general@postgresql.org; pgsql-admin
Is it possible to log all sql statements submitted to database server in a
table in that database it self? This will be different from database logs
which are written by db server.
Regards,
CPK
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: logging SQL statements
2008-10-09 13:23 logging SQL statements c k <shreeseva.learning@gmail.com>
@ 2008-10-09 20:40 ` Greg Smith <gsmith@gregsmith.com>
1 sibling, 0 replies; 4+ messages in thread
From: Greg Smith @ 2008-10-09 20:40 UTC (permalink / raw)
To: c k <shreeseva.learning@gmail.com>; +Cc: pgsql-general@postgresql.org
On Thu, 9 Oct 2008, c k wrote:
> Is it possible to log all sql statements submitted to database server in
> a table in that database it self?
It's possible to cobble together something to appoximate that without too
much trouble if you're running V8.3. You can use the CSV log format to
make the logs show up in a tabular fashion:
http://www.postgresql.org/docs/current/static/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSV...
And then you can change log_statement (on that same page) to "all". The
main tricky part is that you need to account for log rotation and such
with whatever approach you take; you're on your own to figure out when the
server is finished with a log such that you can import it, or to write
something that imports more often. It's possible to write something to
use a "tail -f" type of approach that imports after every line is read,
but that's harder.
BTW: I'm dropping the admin list from my reply here because I'm not
subscribed to that one at the moment. It's bad form to cross-post to
multiple lists here. Pick the one you think you're more likely to get a
response on first, and only if you don't get anything useful back after a
wait should you submit your question to a second list.
--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: logging SQL statements
2008-10-09 13:23 logging SQL statements c k <shreeseva.learning@gmail.com>
@ 2008-10-10 07:57 ` Jagadeesh <mnjagadeesh@gmail.com>
2008-10-11 01:27 ` Re: logging SQL statements IJS/System - Joko <system@ijs.co.id>
1 sibling, 1 reply; 4+ messages in thread
From: Jagadeesh @ 2008-10-10 07:57 UTC (permalink / raw)
To: pgsql-admin
On Oct 9, 6:23 pm, shreeseva.learn...@gmail.com ("c k") wrote:
> Is it possible to log all sql statements submitted to database server in a
> table in that database it self? This will be different from database logs
> which are written by db server.
> Regards,
> CPK
I am not confident but it should be posible. some settings like debug
would log every thing in a logfile.
Will check more on this and update.
Thanks
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: logging SQL statements
2008-10-09 13:23 logging SQL statements c k <shreeseva.learning@gmail.com>
2008-10-10 07:57 ` Re: logging SQL statements Jagadeesh <mnjagadeesh@gmail.com>
@ 2008-10-11 01:27 ` IJS/System - Joko <system@ijs.co.id>
0 siblings, 0 replies; 4+ messages in thread
From: IJS/System - Joko @ 2008-10-11 01:27 UTC (permalink / raw)
To: pgsql-admin
It's surely possible.
Just enable this at postgresql.conf:
log_destination = 'stderr'
redirect_stderr = on
And then choose what to log:
log_statement = 'all'
Valid values are none, ddl, mod, and all. ddl logs all data definition
commands like CREATE, ALTER, and DROP commands. mod logs all ddl
statements, plus INSERT, UPDATE, DELETE, TRUNCATE, and COPY FROM.
PREPARE and EXPLAIN ANALYZE statements are also logged if their
contained command is of an appropriate type.
And u can modify other variables as you want.
Regards,
Joko [IT/EDP]
PT. Indra Jaya Swastika
Phone: +62 31 7481388 Ext 201
http://www.ijs.co.id
Jagadeesh wrote:
> On Oct 9, 6:23 pm, shreeseva.learn...@gmail.com ("c k") wrote:
>
>> Is it possible to log all sql statements submitted to database server in a
>> table in that database it self? This will be different from database logs
>> which are written by db server.
>> Regards,
>> CPK
>>
>
> I am not confident but it should be posible. some settings like debug
> would log every thing in a logfile.
> Will check more on this and update.
> Thanks
>
>
--
If you have any problem with our services ,
please contact us at 70468146 or e-mail: helpdesk@ijs.co.id
PT Indra Jaya Swastika | Jl. Kalianak Barat 57A | +62-31-7481388
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2008-10-11 01:27 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-10-09 13:23 logging SQL statements c k <shreeseva.learning@gmail.com>
2008-10-09 20:40 ` Greg Smith <gsmith@gregsmith.com>
2008-10-10 07:57 ` Jagadeesh <mnjagadeesh@gmail.com>
2008-10-11 01:27 ` IJS/System - Joko <system@ijs.co.id>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox