Skip site navigation (1) Skip section navigation (2)

Re: circular stderr logging - truncation issue

From: vk <vk(dot)mlists(at)gmail(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: circular stderr logging - truncation issue
Date: 2008-09-27 01:11:18
Message-ID: 48DD8836.9070106@gmail.com (view raw or flat)
Thread:
Lists: pgsql-general
note,  I tried both with "#log_rotation_size = 10MB " - 
commented/default, and then enabled it as per documentation page both 
having similar result - no truncation.
there is example on that documentation page that suggests that both size 
and time based rotation could be possible while truncation is enabled - 
which seem to contradict configuration's file comments:
log_truncate_on_rotation = on           # If on, an existing log file of 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.

Also, in my original post there was a typo: I'm watching pg_log/ dir "  
, not pg_logs/ dir

Thanks!

vk wrote:
> Hello everyone!
> I'm trying to implement circular stderr logging:
> postgresql 8.3.4 compiled from src
> fedora 6 x86_64, Intel Core 2 Duo, 2GB RAM
> /usr/local/pgsql/ partition mounted noatime
>
> based on the following document managing circular/logging should be 
> possible:
> http://www.postgresql.org/docs/current/static/runtime-config-logging.html
>
> however, I'm unable to implement it the way it is described on that 
> page, pg_logs/ logs just keep on appending and not truncating as needed:
>
> here are my logging settings (grep "^log_" and grep "^#log_" 
> postgresql.conf ):
>
> #log_destination = 'stderr'             # Valid values are 
> combinations of
> #log_directory = 'pg_log'               # directory where log files 
> are written,
> #log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'        # log file 
> name pattern,
> #log_min_messages = notice              # values in order of 
> decreasing detail:
> #log_error_verbosity = default          # terse, default, or verbose 
> messages
> #log_min_error_statement = error        # values in order of 
> decreasing detail:
> #log_checkpoints = off
> #log_connections = off
> #log_disconnections = off
> #log_duration = off
> #log_hostname = off
> #log_lock_waits = off                   # log lock waits >= 
> deadlock_timeout
> #log_statement = 'none'                 # none, ddl, mod, all
> #log_temp_files = -1                    # log temporary files equal or 
> larger
> #log_timezone = unknown                 # actually, defaults to TZ 
> environment
> #log_parser_stats = off
> #log_planner_stats = off
> #log_executor_stats = off
> #log_statement_stats = off
> log_filename = 'postgresql.log.%S'
> log_truncate_on_rotation = on           # If on, an existing log file 
> of the
> log_rotation_age = 1min                 # Automatic rotation of 
> logfiles will
> log_rotation_size = 10MB                # Automatic rotation of 
> logfiles will
> log_min_duration_statement = 0  # -1 is disabled, 0 logs all statements
> log_line_prefix = '%t [%p]: [%l-1] %h '                 # special values:
> log_autovacuum_min_duration = 0         # -1 disables, 0 logs all 
> actions and
>
> note the above config is prof of concept only, I'm not going to rotate 
> logs every second on production.
> for production I intend to have
> "log_rotation_age = 1 h"
> "log_filename = postgresql.log.%M"
>
> I'm using pgbench to generate db/logs traffic:
>
> while (true); do date; pgbench -s 5000 -c 10 -t 5000 PGBENCH; done
>
> meanwhile watching pg_log dir:
>
> after 50 minutes or so of this testing I never saw any log file to 
> drop in size. after looking through individual log files, I confirm 
> that old data is still there, and new data is just appended at the 
> bottom.
>
> how can I get truncate to work properly in this setup ? could you 
> point me in the right direction ?
> or could this be a bug ..
>
> Thanks !
> Vlad
>
>


In response to

pgsql-general by date

Next:From: Alain RogerDate: 2008-09-27 07:13:48
Subject: only the last 3 records
Previous:From: vkDate: 2008-09-27 00:43:12
Subject: circular stderr logging - truncation issue

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group