On Wednesday 20 August 2003 11:09, Ramil Sagum wrote:
> > Make it log queries in /var/log/messages or syslog. :)
> >
> :winces: How do you implement it?
i was interested in this too, so i played with a test system. this is
Postgresql 7.3.2 as it comes stock with Mandrake 9.1.
in /var/lib/pgsql/data/postgresql.conf:
# not sure what the minimum setting should be for this, might
# not matter, but it's what my config says :).
server_min_messages = notice
#ditto
client_min_messages = notice
# default setting. i didn't change it
#silent_mode = false
# two default settings.
#log_connections = false
#log_pid = false
# i changed these settings. i think they were false initially.
log_statement = true
log_duration = true
log_timestamp = true
# i changed this. but it probably isn't necessary, the default
# is probably fine. it's just, i don't remember what the default
# was (and i don't want to remove the RPM and put it back in :).
log_min_error_statement = info
# i also modified these (default was LOCAL0, but that conflicts
# with something, choose something good for you).
syslog = 2 # range 0-2
syslog_facility = 'LOCAL2'
syslog_ident = 'postgres'
then configure syslog.conf to put logs bound for LOCAL2 into the
right file.
in my /etc/syslog.conf i have:
local2.* -/var/log/postgres.log
and create that file and set permissions (on my system,
as root,
touch /var/log/postgres.log
chown postgres.postgres /var/log/postgres.log
chmod u+rwx,g+rx,o-rwx /var/log/postgres.log
then stop and start (or just reload the config) both syslog and
postgres.
service syslog stop
service postgresql stop
service syslog start
service postgresql start
i don't like using reload, restart, force-reload, etc, but
then i don't run enterprise servers with hundreds of hits
a minute :). if i did, i'd probably use reload or restart :).
after i do that, i start getting this:
Aug 20 11:19:32 tiger-nb postgres[5699]: [7] LOG: statement: insert into test
values(3);
Aug 20 11:19:36 tiger-nb postgres[5702]: [1] LOG: query: begin; select
getdatabaseencoding(); commit
Aug 20 11:19:36 tiger-nb postgres[5702]: [2] LOG: duration: 0.004141 sec
Aug 20 11:19:38 tiger-nb postgres[5702]: [5] LOG: query: insert into test
values(3);
Aug 20 11:19:38 tiger-nb postgres[5702]: [6] LOG: duration: 0.007634 sec
Aug 20 11:19:42 tiger-nb postgres[5702]: [7] LOG: query: delete from test;
Aug 20 11:19:42 tiger-nb postgres[5702]: [8] LOG: duration: 0.005530 sec
you could just grep on query: or just set log_duration=false.
pretty neat :).
warning: i did not actually log everything i did, so i may have forgotten
something or other in the account above :). you'll figure it out though,
it's all pretty trivial once you figure out what the right postgresql.conf
entries are.
warning 2: i was just playing. so i didn't spend the time to figure out
what the minimal postgresql.conf settings were that would allow this.
i just turned on some things that seemed reasonable. the settings could
probably be tweake
tiger
--
Gerald Timothy Quimpo gquimpo*hotmail.com tiger*sni*ph
http://bopolissimus.sni.ph
Public Key: "gpg --keyserver pgp.mit.edu --recv-keys 672F4C78"
No battle plan ever survives contact with the enemy.
Helmuth von Moltke
--
Philippine Linux Users' Group (PLUG) Mailing List
[EMAIL PROTECTED] (#PLUG @ irc.free.net.ph)
Official Website: http://plug.linux.org.ph
Searchable Archives: http://marc.free.net.ph
.
To leave, go to http://lists.q-linux.com/mailman/listinfo/plug
.
Are you a Linux newbie? To join the newbie list, go to
http://lists.q-linux.com/mailman/listinfo/ph-linux-newbie