pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
way to turn off epochs in log_filename
9+ messages / 4 participants
[nested] [flat]

* way to turn off epochs in log_filename
@ 2007-10-26 18:10  David Lowry <dlowry@bju.edu>
  0 siblings, 2 replies; 9+ messages in thread

From: David Lowry @ 2007-10-26 18:10 UTC (permalink / raw)
  To: pgsql-admin

Hi,
The docs state that if there are no %-escapes in log_filename, then  
it will add the epoch onto the end of the log filename. Is there any  
way to turn off this behavior and just use the filename specified in  
log_filename? I'd like have all the log data written to a file like  
postgresql.log and let logrotate do the rotation.

Thanks for any help!

-- 
David Lowry
Systems Administrator
Bob Jones University
dlowry@bju.edu
(864)370-1800 ext. 4149

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: way to turn off epochs in log_filename
@ 2007-10-26 20:25  Peter Koczan <pjkoczan@gmail.com>
  parent: David Lowry <dlowry@bju.edu>
  1 sibling, 0 replies; 9+ messages in thread

From: Peter Koczan @ 2007-10-26 20:25 UTC (permalink / raw)
  To: David Lowry <dlowry@bju.edu>; +Cc: pgsql-admin

> The docs state that if there are no %-escapes in log_filename, then it will
> add the epoch onto the end of the log filename. Is there any way to turn off
> this behavior and just use the filename specified in log_filename? I'd like
> have all the log data written to a file like postgresql.log and let
> logrotate do the rotation.

Correct me if I'm wrong, but I think you're trying to redirect stderr.
Why not just use syslog? That's what I use and it works very nicely.

Here are the relevant bits from postgresql.conf (that aren't related
to log formatting and changed from the default).
log_destination = 'syslog'
syslog_facility = 'LOCAL1'

Just make sure you pipe the syslog facility to postgresql.log, and
then you can use logrotate.

Peter



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: way to turn off epochs in log_filename
@ 2007-10-26 21:33  Tom Lane <tgl@sss.pgh.pa.us>
  parent: David Lowry <dlowry@bju.edu>
  1 sibling, 1 reply; 9+ messages in thread

From: Tom Lane @ 2007-10-26 21:33 UTC (permalink / raw)
  To: David Lowry <dlowry@bju.edu>; +Cc: pgsql-admin

David Lowry <dlowry@bju.edu> writes:
> The docs state that if there are no %-escapes in log_filename, then  
> it will add the epoch onto the end of the log filename. Is there any  
> way to turn off this behavior and just use the filename specified in  
> log_filename? I'd like have all the log data written to a file like  
> postgresql.log and let logrotate do the rotation.

If logrotate would work, we'd never have bothered writing our own
substitute.  But there's no way for logrotate to repoint postmaster's
stderr into other files.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: way to turn off epochs in log_filename
@ 2007-10-26 21:40  Joshua D. Drake <jd@commandprompt.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 9+ messages in thread

From: Joshua D. Drake @ 2007-10-26 21:40 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: David Lowry <dlowry@bju.edu>; pgsql-admin

On Fri, 26 Oct 2007 17:33:15 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> David Lowry <dlowry@bju.edu> writes:
> > The docs state that if there are no %-escapes in log_filename,
> > then it will add the epoch onto the end of the log filename. Is
> > there any way to turn off this behavior and just use the filename
> > specified in log_filename? I'd like have all the log data written
> > to a file like postgresql.log and let logrotate do the rotation.
> 
> If logrotate would work, we'd never have bothered writing our own
> substitute.  But there's no way for logrotate to repoint postmaster's
> stderr into other files.

Uh... can't we just use copytruncate with logroate? That way
we don't have to repoint. That is how we do it anyway... Or am I missing
something?

Joshua D. Drake


> 
> 			regards, tom lane
> 
> ---------------------------(end of
> broadcast)--------------------------- TIP 1: if posting/reading
> through Usenet, please send an appropriate subscribe-nomail command
> to majordomo@postgresql.org so that your message can get through to
> the mailing list cleanly
> 


-- 

      === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564   24x7/Emergency: +1.800.492.2240
PostgreSQL solutions since 1997  http://www.commandprompt.com/
			UNIQUE NOT NULL
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/

Attachments:

  signature.asc (application/pgp-signature, 188B) download

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: way to turn off epochs in log_filename
@ 2007-10-26 21:45  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Joshua D. Drake <jd@commandprompt.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2007-10-26 21:45 UTC (permalink / raw)
  To: Joshua D. Drake <jd@commandprompt.com>; +Cc: David Lowry <dlowry@bju.edu>; pgsql-admin

"Joshua D. Drake" <jd@commandprompt.com> writes:
> Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> If logrotate would work, we'd never have bothered writing our own
>> substitute.  But there's no way for logrotate to repoint postmaster's
>> stderr into other files.

> Uh... can't we just use copytruncate with logroate?

How's that going to reset the offsets in the stderr file descriptors of
the various PG processes?  There might be some platforms and
configurations where it will work, but I wouldn't tout it as a portable
approach.  I'd also suppose that there are race conditions involved:
you'll either lose or duplicate messages that are emitted while
copytruncate works.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: way to turn off epochs in log_filename
@ 2007-10-26 22:42  Joshua D. Drake <jd@commandprompt.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 9+ messages in thread

From: Joshua D. Drake @ 2007-10-26 22:42 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: David Lowry <dlowry@bju.edu>; pgsql-admin

On Fri, 26 Oct 2007 17:45:00 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> "Joshua D. Drake" <jd@commandprompt.com> writes:
> > Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> If logrotate would work, we'd never have bothered writing our own
> >> substitute.  But there's no way for logrotate to repoint
> >> postmaster's stderr into other files.
> 
> > Uh... can't we just use copytruncate with logroate?
> 
> How's that going to reset the offsets in the stderr file descriptors
> of the various PG processes?  There might be some platforms and
> configurations where it will work, but I wouldn't tout it as a
> portable approach.  I'd also suppose that there are race conditions
> involved: you'll either lose or duplicate messages that are emitted
> while copytruncate works.

Yeah, we have seen that, where the log will be missing a few
statements. Good point.

Joshua D. Drake

> 
> 			regards, tom lane
> 


-- 

      === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564   24x7/Emergency: +1.800.492.2240
PostgreSQL solutions since 1997  http://www.commandprompt.com/
			UNIQUE NOT NULL
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/

Attachments:

  signature.asc (application/pgp-signature, 188B) download

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: way to turn off epochs in log_filename
@ 2007-10-27 15:14  David Lowry <dlowry@bju.edu>
  parent: Joshua D. Drake <jd@commandprompt.com>
  0 siblings, 1 reply; 9+ messages in thread

From: David Lowry @ 2007-10-27 15:14 UTC (permalink / raw)
  To: Joshua D.Drake <jd@commandprompt.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-admin

On Oct 26, 2007, at 6:42 PM, Joshua D. Drake wrote:
>>>> If logrotate would work, we'd never have bothered writing our own
>>>> substitute.  But there's no way for logrotate to repoint
>>>> postmaster's stderr into other files.
>>
>>> Uh... can't we just use copytruncate with logroate?
>>
>> How's that going to reset the offsets in the stderr file descriptors
>> of the various PG processes?  There might be some platforms and
>> configurations where it will work, but I wouldn't tout it as a
>> portable approach.  I'd also suppose that there are race conditions
>> involved: you'll either lose or duplicate messages that are emitted
>> while copytruncate works.
>
> Yeah, we have seen that, where the log will be missing a few
> statements. Good point.

If I'm not mistaken, it would be more of a move combined with  
creating a new file. My impression was that the sequence worked  
something like this:

1. Logrotate moves the old log file to a new name, equivalent to  
something like this:
mv postgresql.log postgresql.log.1
In the mean time, PG keeps writing to the same file.
2. Logrotate sends a HUP (as configured in the logrotate conf) to the  
postmaster process, which causes PG to close the old log file  
(postgresql.log.1) and open a new one (postgresql.log).

If I understand correctly, you're saying that this process either  
won't work or isn't portable. Is that correct?

BTW, my rational is that we use logrotate for most of our other logs,  
so I would like to put PG in the same system. If what I suggested  
above won't work, I'll just set up PG to write to something like  
postgresql.log_20070101 and write a script to gzip and clean up old  
logs.



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: way to turn off epochs in log_filename
@ 2007-10-27 15:30  Tom Lane <tgl@sss.pgh.pa.us>
  parent: David Lowry <dlowry@bju.edu>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2007-10-27 15:30 UTC (permalink / raw)
  To: David Lowry <dlowry@bju.edu>; +Cc: Joshua D.Drake <jd@commandprompt.com>; pgsql-admin

David Lowry <dlowry@bju.edu> writes:
> 1. Logrotate moves the old log file to a new name, equivalent to  
> something like this:
> mv postgresql.log postgresql.log.1
> In the mean time, PG keeps writing to the same file.
> 2. Logrotate sends a HUP (as configured in the logrotate conf) to the  
> postmaster process, which causes PG to close the old log file  
> (postgresql.log.1) and open a new one (postgresql.log).

> If I understand correctly, you're saying that this process either  
> won't work or isn't portable. Is that correct?

Specifically, PG does not respond to SIGHUP in the way you are imagining
above.  The log-file-switch capability is either nonexistent (if no log
collector process) or built in (if log collector is active) and there
doesn't seem any value in driving the latter from outside PG.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: way to turn off epochs in log_filename
@ 2007-10-29 12:34  David Lowry <dlowry@bju.edu>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 9+ messages in thread

From: David Lowry @ 2007-10-29 12:34 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Joshua D.Drake <jd@commandprompt.com>; pgsql-admin


On Oct 27, 2007, at 11:30 AM, Tom Lane wrote:
>> 1. Logrotate moves the old log file to a new name, equivalent to
>> something like this:
>> mv postgresql.log postgresql.log.1
>> In the mean time, PG keeps writing to the same file.
>> 2. Logrotate sends a HUP (as configured in the logrotate conf) to the
>> postmaster process, which causes PG to close the old log file
>> (postgresql.log.1) and open a new one (postgresql.log).
>
>> If I understand correctly, you're saying that this process either
>> won't work or isn't portable. Is that correct?
>
> Specifically, PG does not respond to SIGHUP in the way you are  
> imagining
> above.  The log-file-switch capability is either nonexistent (if no  
> log
> collector process) or built in (if log collector is active) and there
> doesn't seem any value in driving the latter from outside PG.

Thanks for clearing that up. I think I'll just go with a script to  
clean up the files.

David




^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2007-10-29 12:34 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-10-26 18:10 way to turn off epochs in log_filename David Lowry <dlowry@bju.edu>
2007-10-26 20:25 ` Peter Koczan <pjkoczan@gmail.com>
2007-10-26 21:33 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-10-26 21:40   ` Joshua D. Drake <jd@commandprompt.com>
2007-10-26 21:45     ` Tom Lane <tgl@sss.pgh.pa.us>
2007-10-26 22:42       ` Joshua D. Drake <jd@commandprompt.com>
2007-10-27 15:14         ` David Lowry <dlowry@bju.edu>
2007-10-27 15:30           ` Tom Lane <tgl@sss.pgh.pa.us>
2007-10-29 12:34             ` David Lowry <dlowry@bju.edu>

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