PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹17. 橉媇単陉䘞媆誕嬉誕

17.7. 髍臇檖只启斖媖

17.7.1. 婘巻麯螄嘘斖媖

log_destination (string)

PostgreSQL 櫇毕崔䓉螄嘘橉媇単斖媖䔇桹濘寙拸 stderrsyslog 㔗婘 Windows 麯誻櫇毕 eventlog 嘩婺斖媖係䂘㔗檪認婻锬釹螆䘞婺婔婻锖埙彖锫䔇斖媖䕞湺䔇彖臘㔗䚺䩕滇埻螄嘘彄 stderr 㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗

redirect_stderr (boolean)

認婻锬釹噕螩檪闼底埏锕彄 stderr 䔇潽敇托诙婋準䇽劯檪垄傸麉垔劏彄斖媖桺傽麯㔗認婻锬釹锔婩懫螄嘘彄 syslog 敘橬䫘啹婺橬底潽敇䌂傋婉庺䯄婘 syslog 膷庺婺(婔婻婩蓕䔇冋床滇媘攕誂毖崌蘖䔇潽敇)㔗認婻唚埻脘婘橉媇単劇媘䔇施唍螆䘞㔗

log_directory (string)

婘欷嚔庖 redirect_stderr 䔇施唍認婻锬釹彴桺斖媖桺傽婘巻婻䕞嘘麯录傺㔗垄埇傖弄滯潊䂺凹虇冇潡蔙滇婯镖䆴䔇昄扞䕞嘘䕩凹䔇虇冇㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗

log_filename (string)

婘欷嚔庖 redirect_stderr 䔇施唍認婻锬釹螆䘞欔录傺䔇斖媖桺傽䔇桺傽劉㔗認婻昄唚儖赆嘷嘩 strftime 昇嚟䩋写㔗啹溴埇傖䫘 % 锄锩弄滯锟施閘蔯埻䔇桺傽劉㔗套悩澇橬庺䯄 % 锄锩PostgreSQL 儖躻媘鍇媹斖媖桺傽欷嚔䔇施閘潿㔗懫套套悩 log_filename 螆䘞婺 server_log 闼幽嚔哋庯 Sun Aug 29 19:02:33 2004 MST 䔇斖媖桺傽䔇劉䓄儖滇 server_log.1093827753 㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗

log_rotation_age (integer)

婘欷嚔庖 redirect_stderr 䔇施唍認婻锬釹螆䘞婔婻䋸䆋斖媖桺傽䔇橔崓䫘庻橘㔗婘昄唚毺垔䔇彖鐘誺寂幋劯儖录傺婔婻桄䔇斖媖桺傽㔗螆䘞婺镽埇傖噿閺傖施閘婺嘺䇔䔇桄斖媖桺傽䔇录傺㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗

log_rotation_size (integer)

婘欷嚔庖 redirect_stderr 䔇施唍認婻锬釹螆䘞婔婻䋸䆋䔇斖媖桺傽䔇橔崓儺凩㔗婘昄唚毺垔䔇剄庖誗喍噖斖媖桺傽幋劯儖嚔录傺婔婻桄䔇斖媖桺傽㔗螆䘞婺镽埇傖噿閺傖儺凩婺嘺䇔䔇桄斖媖桺傽䔇录傺㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗

log_truncate_on_rotation (boolean)

婘欷嚔庖 redirect_stderr 䔇施唍認婻锬釹儖凚躘 PostgreSQL 襖䕡蔯婉滇鍇媹彄傂嘘劯劉䔇䯄橬斖媖桺傽婪㔗婉誺襖䕡埻滇埏䫘婘嘺庯施閘悔媘蔯录傺䔇桄桺傽婪蔯婉滇婘橉媇単劇媘䔇施唍潡蔙傖儺凩婺嘺䇔䔇悔媘婪㔗套悩婺 off 儖哋䂽劏噾庻婘䔇桺傽䂷儆誘媹㔗懫套嘪䫘認婻锬釹启䌂嚚 postgresql-%H.log 認湙䔇 log_filename 螆䘞儖凚躘䫘潊 24 婻毬償施䫘潊䔇斖媖桺傽䇽劯婘認底桺傽婪冻䯇㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗

冋床媺䘍 7 崷䔇斖媖懟崷婔婻斖媖桺傽埆啔 server_log.Mon, server_log.Tue 京京幽婫婪变䔇斖媖嚔躻媘赆認变䔇斖媖襖䕡㔗檪 log_filename 螆䘞婺 server_log.%a 㔕檪 log_truncate_on_rotation 螆䘞婺 on 㔕檪 log_rotation_age 螆䘞婺 1440

冋床媺䘍 24 償施䔇斖媖懟償施婔婻斖媖嘖滇套悩斖媖桺傽儺凩崓庯 1GB 幘斋蘸斖媖㔗檪 log_filename 螆䘞婺 server_log.%H%M 㔕檪 log_truncate_on_rotation 螆䘞婺 on 㔕檪 log_rotation_age to 60 㔕檪 log_rotation_size 螆䘞婺 1000000 㔗婘 log_filename 麯寙劆 %M 噕螩傂嘘儺凩鷌媘䔇斋蘸锬埡婔婻启嚔哋䔇桺傽劉劯償施昄嘖滇劉庖婉劯䔇桺傽㔗

syslog_facility (string)

套悩劏 syslog 誕臯螄嘘闼幽認婻锬釹彴桺襕嘪䫘䔇 syslog "螆桘"㔗嘹埇傖傯 LOCAL0(邻螴), LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7 婺锬拷㔗埽蓕嘹䔇係䂘䔇 syslog 垽檴誕䘋桺懼㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗

syslog_ident (string)

套悩劏 syslog 誕臯螄嘘認婻锬釹喿垔䫘庯婘 syslog 斖媖婺湺臖 PostgreSQL 䔇䘋废劉㔗䚺䩕滇 postgres 㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗

17.7.2. 傔幽施唍螄嘘斖媖

client_min_messages (string)

認婻锬釹毓彽巻底媇敇埏锕彄垵潙䆇㔗橬昽䔇昄唚滇 DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, LOG, NOTICE, WARNING, ERROR, FATAL, PANIC 㔗懟婻亓彆寙劆欔橬垄劯麵䔇亓彆亓彆轪麹劯埏锕䔇媇敇轪儏㔗䚺䩕滇 NOTICE 㔗驔襕濘懟䔇滇認麯䔇 LOGlog_min_messages 麯䔇亓彆婉劯㔗

log_min_messages (string)

毓彽喍彄橉媇単斖媖麯䔇媇敇䔇臥䂖䘋庥㔗橬昽唚滇 DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, INFO, NOTICE, WARNING, ERROR, LOG, FATAL, PANIC 㔗懟婻亓彆鄘寙劆垄劯麵䔇亓彆㔗轪麹劯䔇昄唚埏冔橉媇単斖媖䔇媇敇轪儏㔗䚺䩕滇 NOTICE 㔗驔襕濘懟䔇滇認麯䔇 LOGclient_min_messages 麯䔇亓彆婉劯㔗埻橬轙亓䫘潙埇傖媞櫹認婻螆䘞㔗

log_error_verbosity (string)

毓彽螄嘘䔇懟溇媇敇喍彄橉媇単斖媖麯䔇臥䂖䘋庥㔗橬昽䔇唚滇 TERSE, DEFAULT, VERBOSE 锊婻劏滆䴺䔇媇敇麯嵂媹敘崔䔇庖枕㔗埻橬轙亓䫘潙埇傖櫹埻認婻螆䘞㔗

log_min_error_statement (string)

毓彽滇劥婘橉媇単斖媖麯膷庺闼底凚躘髍臇溇傽䔇 SQL 臺埖㔗欔橬凚躘婔婻䬹垔亓彆(潡蔙敘醻亓彆)髍臇䔇 SQL 臺埖鄘襕赆螄嘘㔗橬昽䔇唚橬 DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, INFO, NOTICE, WARNING, ERROR, FATAL, PANIC 㔗䚺䩕滇 ERROR 臘䴺欔橬凚躘髍臇㔕躘变髍臇㔕敊景䔇 SQL 臺埖鄘儖赆螄嘘㔗螆䘞婺 PANIC 臘䴺檪認婻䬹攓噿閺㔗埻橬轙亓䫘潙埇傖櫹埻認婻螆䘞㔗

log_min_duration_statement (integer)

套悩昊婻臺埖䔇毕䂺施閘崓庯潡蔙京庯認婻懆䓐昄闼幽婘斖媖臯婪螄嘘臖臺埖埪噽毕䂺施閘㔗螆䘞婺镽儖欷剄欔橬昖臵启傡傸䔇毕䂺施閘㔗螆䘞婺-1(䚺䩕唚)噿閺認婻媘脘㔗懫套套悩嘹檪垄螆䘞婺 250ms 闼幽欔橬誊臯施閘京庯潡蔙轙誺 250ms 䔇 SQL 臺埖鄘嚔赆螄嘘㔗欷嚔認婻锬釹埇傖冽桹冪婄虘詻驔襕嚻寡䔇昖臵㔗埻橬轙亓䫘潙埇傖櫹埻認婻螆䘞㔗

凹庯嘪䫘欷匘昖臵剟螞䔇垵潙䆇臺濘彖悊㔕闥垔㔕欓臯懟婔準欔誌施閘鄘彖彆螄嘘㔗

㔊濘懟㔏嘷溴锬釹婯 log_statement 劯施嘪䫘施噾䂟赆 log_statement 螄嘘䔇臺埖桺橸婉嚔赆麉崉螄嘘㔗套悩澇橬嘪䫘 syslog 䔇臺毘艊嘪䫘 log_line_prefix 螄嘘 PID 潡嚔臺 ID 認湙儌埇傖嘪䫘垄傸儖臺埖潽敇誂毖蔖施潽敇㔗

silent_mode (boolean)

垬麍䔇誊臯橉媇単㔗套悩螆䘞庖認婻锬釹橉媇単儖躻媘婘劯埄誊臯幽婫婯毓彽䂽䆇臌嚔㔗橉媇単䔇湺庖膷庺启湺庖髍臇儖麉垔劏彄 /dev/null 啹溴埏锕䔇傂嘘媇敇鄘儖婵崌㔗鍴麂欷嚔庖 syslog 斖媖潡蔙 redirect_stderr 劥彍潏傸婉傺螞嘪䫘認婻锬釹啹婺垄螷潏傸冽锆䩋彄髍臇媇敇㔗認婻唚埻脘婘橉媇単劇媘䔇施唍螆䘞㔗

認麯滇認婻螆䘞麯䫘彄劇䓉媇敇婖麉䘋庥䌂傋䔇婔婻彖臘

DEBUG[1-5]

柊冕嚔埏庺叻嘪䫘䔇媇敇㔗

INFO

柊冕䫘潙锊劆襕挗䔇媇敇懫套婘 VACUUM VERBOSE 誺䘋婺䔇媇敇㔗

NOTICE

柊冕埇脘凹䫘潙橬婞媷䔇媇敇懫套阪湺臖严䔇潻桺嘩婺婂髞婔鄘彖录傺䔇䘵嚘㔗

WARNING

柊冕䂍䫘潙䔇躥只懫套婘庋媇庖评啘幋崡䔇 COMMIT

ERROR

檖只凚躘嘷嬉变傴锔庺䔇髍臇㔗

LOG

檖只婔底䞇䊖叻懘噘轼䔇媇敇懫套演昖䗹昂虄攓㔗

FATAL

檖只凚躘嘷嬉嚔臺䂽溵䔇寘啹㔗

PANIC

檖只凚躘欔橬嚔臺锔庺䔇寘啹㔗

17.7.3. 螄嘘傔幽

debug_print_parse (boolean)
debug_print_rewritten (boolean)
debug_print_plan (boolean)
debug_pretty_print (boolean)

認底锬釹欷嚔劇䓉脄臘膷庺㔗凹庯欓臯䔇懟婻昖臵垄傸欷剄䫘潊䔇彖悊湏㔕昖臵麉喍潡蔙欓臯蓇彐㔗debug_pretty_print 檪認底膷庺誕臯䚷誕嚔䫘潊滷臂嘖滇阪婔底䔇膷庺湚嚟㔗client_min_messageslog_min_messages 媙釂滇 DEBUG1 潡蔙敘嘯欉檪膷庺垂鍙埏冔垵潙䆇潡蔙橉媇単斖媖㔗認底锬釹䚺䩕鄘滇噿閺䔇㔗

log_connections (boolean)

婘懟渇潊媘誂毖䔇施唍鄘劏橉媇単斖媖麯欷剄婔臯臥䂖媇敇㔗䚺䩕施滇噿閺䔇儘䞇垄埇脘冽橬䫘㔗橬底垵潙䆇䘋废懫套 psql 婘彴桺滇劥驔襕埼傴䔇施唍臘商誂毖婴渇啹溴麉崉䔇"connection receive"(櫽彄誂毖臙挗)幽婉懟叿五婔垔滇閞鵻㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗

log_disconnections (boolean)

認婻锬釹䌂嚚 log_connections 嘖滇婘嚔臺䂷溘䔇施唍婘橉媇単斖媖麯膷庺婔臯㔗䚺䩕滇噿閺䔇㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗

log_duration (boolean)

螄嘘懟婻噾垯潊臺埖䔇毕䂺施閘㔗邻螴唚滇 off 㔗埻橬轙亓䫘潙埇傖櫹埻認婻螆䘞㔗

凹庯嘪䫘欷匘昖臵剟螞䔇垵潙䆇臺濘彖悊㔕闥垔㔕欓臯懟婔準欔誌施閘鄘彖彆螄嘘㔗

㔊濘懟㔏螆䘞婺 0 施臖锬釹婯 log_min_duration_statement 䔇婉劯幋崇婘庯 log_min_duration_statement 嚺彽螄嘘昖臵桺橸㔗啹溴套悩 log_durationon 幽婫 log_min_duration_statement 崓庯镽儖螄嘘欔橬毕䂺施閘嘖滇備螄嘘闼底轙誺黽唚䔇臺埖㔗認埇傖䫘庯婘醻蘘蘘愙喕婋抩镖䂘螇媇敇㔗

log_line_prefix (string)

認滇婔婻 printf 鼯湚䔇庖严婾婘斖媖䔇懟臯嚔崘膷庺㔗䚺䩕滇䷺庖严婾㔗婋麵彖庺懟婻埇臖彆䔇锄锩傂嘘噽垄䩋蕙準償锄锩䔇鄘嚔赆媘䘖㔗噽垄庖严鄘䕘毖拙蘺彄斖媖臯婺㔗橬底锄锩埻赆嚔臺誕䘋臖彆婉脘庫䫘庯劯䆇誕䘋懫套婂橉媇単誕䘋㔗Syslog 䫘潊躻噌䔇施閘潿启誕䘋 ID 媇敇啹溴套悩嘹嘪䫘庖 syslog 埇脘澇媙襕嘪䫘闼底锄锩㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗

锄锩昽悩備䫘庯嚔臺
%u䫘潙劉
%d昄扞康劉
%r誩䘋婂橺劉潡蔙 IP 婄应傖埪誩䆇䆇埼
%h誩䘋婂橺劉潡蔙 IP 婄应
%p誕䘋 ID
%t施閘潿(澇橬懆䓐Windows 婪澇橬施寺)
%m婥懆䓐䔇施閘潿
%i变傴湺了㔗認滇䫘潊斖媖臯䔇变傴㔗
%c嚔臺 ID 㔗懟婻嚔臺䔇嫇婔湺臖严㔗垄滇婴婻 4 庖誗䔇剕噺誕彽昄庖(澇橬嬉凚镽)䫘埖䗹彖嚔㔗昄庖滇嚔臺嚔哋施閘启誕䘋 ID 啹溴幘埇傖䫘啔婔䓉欷剄認底釹䕞䔇誗亥䷺閘䔇桹濘㔗
%l懟婻誕䘋䔇斖媖臯䚡埙傯 1 嚔哋㔗
%s嚔臺嚔哋䔇施閘潿
%x庋媇 ID
%q婉䫘潊傂嘘膷庺嘖滇只臬麂嚔臺誕䘋婘庖严婾䔇認婻嘉䘞啩溵㔗赆嚔臺誕䘋媘䘖㔗
%%% 桺橸

log_statement (string)

毓彽螄嘘巻底 SQL 臺埖㔗橬昽䔇唚滇 none, ddl, mod, allddl 螄嘘欔橬昄扞垔幬变傴懫套 CREATE, ALTER, DROP 臺埖㔗mod 螄嘘欔橬 ddl 臺埖媹婪昄扞媞櫹臺埖 INSERT, UPDATE, DELETE, TRUNCATE, COPY FROM 㔗套悩欔寙劆䔇变傴䌂傋劂劽闼幽 PREPARE, EXECUTE, EXPLAIN ANALYZE 臺埖幘劯湙赆螄嘘㔗凹庯嘪䫘欷匘昖臵剟螞䔇垵潙䆇螄嘘埏䫘婘毖埖彄欷匘媇敇幽寙劆闥垔埗昄(喙䘞剘嚘埙襕埯喍)䔇施唍㔗

䚺䩕滇 none 㔗埻橬轙亓䫘潙埇傖櫹埻認婻螆䘞㔗

㔊濘懟㔏剿嘪螆䘞庖 log_statement = all 寙劆䞔剘臺濘髍臇䔇臺埖幘婉嚔赆螄嘘㔗啹婺備婘垯潊嘺橸䔇臺濘彖悊幽䇞垔庖臺埖䌂傋幋劯欉螄嘘斖媖㔗婘嘪䫘欷匘昖臵剟螞䔇愙喕婋婘欓臯黽枕幋嬉(臺濘彖悊潡蓇彐黽枕)劯湙婉嚔螄嘘㔗儖 log_min_error_statement 螆婺 ERROR 潡敘嘯欉脘螄嘘認底臺埖㔗

log_hostname (boolean)

䚺䩕施誂毖斖媖埻螄嘘欔誂毖婂橺䔇 IP 婄应㔗欷嚔認婻锬釹凚躘劯施螄嘘婂橺劉㔗臙濘懟認湙橬埇脘婥準婔底婉埇媘䘖䔇攓脘托崌(埡喿庯嘹䔇劉庖蓼悊䔇螆䘞)㔗認婻锬釹埻脘婘橉媇単劇媘䔇施唍潡蔙婘 postgresql.conf 桺傽麯螆䘞㔗


劯锔饡釕嬉誕
昖臵蓇彐婪婔亓誊臯施䂘螇