postgres日志configuration

我想将postgres查询logging到csv日志中。

为此,我尝试按照以下说明操作: https : //www.postgresql.org/docs/9.4/static/runtime-config-logging.html

所以在我的configuration文件中我有:

#------------------------------------------------------------------------------ # ERROR REPORTING AND LOGGING #------------------------------------------------------------------------------ # - Where to Log - log_destination = 'csvlog' # Valid values are combinations of # stderr, csvlog, syslog, and eventlog, # depending on platform. csvlog # requires logging_collector to be on. # This is used when logging to stderr: logging_collector = on # Enable capturing of stderr and csvlog # into log files. Required to be on for # csvlogs. # (change requires restart) # These are only used if logging_collector is on: log_directory = 'pg_log' # directory where log files are written, # can be absolute or relative to PGDATA log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, # can include strftime() escapes #log_file_mode = 0600 # creation mode for log files, # begin with 0 to use octal notation #log_truncate_on_rotation = off # If on, an existing log file with the # same name as the new log file will be # truncated rather than appended to. # But such truncation only occurs on # time-driven rotation, not on restarts # or size-driven rotation. Default is # off, meaning append to existing files # in all cases. #log_rotation_age = 1d # Automatic rotation of logfiles will # happen after that time. 0 disables. #log_rotation_size = 10MB # Automatic rotation of logfiles will # happen after that much log output. # 0 disables. # These are relevant when logging to syslog: #syslog_facility = 'LOCAL0' #syslog_ident = 'postgres' # This is only relevant when logging to eventlog (win32): #event_source = 'PostgreSQL' # - When to Log - client_min_messages = log # values in order of decreasing detail: # debug5 # debug4 # debug3 # debug2 # debug1 # log # notice # warning # error log_min_messages = info # values in order of decreasing detail: # debug5 # debug4 # debug3 # debug2 # debug1 # info # notice # warning # error # log # fatal # panic log_min_error_statement = info # values in order of decreasing detail: # debug5 # debug4 # debug3 # debug2 # debug1 # info # notice # warning # error # log # fatal # panic (effectively off) log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements # and their durations, > 0 logs only # statements running at least this number # of milliseconds # - What to Log - #debug_print_parse = off #debug_print_rewritten = off #debug_print_plan = off #debug_pretty_print = on #log_checkpoints = off #log_connections = off #log_disconnections = off #log_duration = off log_error_verbosity = verbose # terse, default, or verbose messages #log_hostname = off log_line_prefix = '%m %u@%d %p %r ' # special values: # %a = application name # %u = user name # %d = database name # %r = remote host and port # %h = remote host # %p = process ID # %t = timestamp without milliseconds # %m = timestamp with milliseconds # %i = command tag # %e = SQL state # %c = session ID # %l = session line number # %s = session start timestamp # %v = virtual transaction ID # %x = transaction ID (0 if none) # %q = stop here in non-session # processes # %% = '%' # eg '<%u%%%d> ' #log_lock_waits = off # log lock waits >= deadlock_timeout log_statement = 'mod' # none, ddl, mod, all #log_temp_files = -1 # log temporary files equal or larger # than the specified size in kilobytes; # -1 disables, 0 logs all temp files #log_timezone = 'Europe/London' 

我想logging的主要信息是命令标签和任何插入,更新,删除等查询…(我真的不关心select)。 为此,我将log_statement设置为mod(仅logging这些命令),并将log_error_verbosity设置为详细(logging所有信息)。 现在,当我运行以下查询:

INSERT INTOtesting(time)VALUES('2017-01-04 17:00:00');

SELECT * FROM tests WHERE id = '70';

我设法只获得插入logging,就像我想,但不是所有的信息显示…

这是日志结果:

 2017-07-19 14:21:44.028 GMT,"postgres","postgres",12892,"::1:1028",596f67e4.325c,8,"idle",2017-07-19 14:08:36 GMT,2/24,0,LOG,00000,"statement: INSERT INTO tests (time) VALUES ('2017-01-04 17:00:00');",,,,,,,,"exec_simple_query, src\backend\tcop\postgres.c:914","pgAdmin III - Query Tool" 

命令标签显示“iddle”,查询不显示,如下所示: https : //www.postgresql.org/docs/9.1/static/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG

任何人都可以告诉我我做错了什么?

笔记:

我在Windows机器上这样做,我已经重新启动postgres服务。