pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedLog rotation
12+ messages / 7 participants
[nested] [flat]
* Log rotation
@ 2002-03-28 18:54 Gaetano Mendola <mendola@bigfoot.com>
0 siblings, 1 reply; 12+ messages in thread
From: Gaetano Mendola @ 2002-03-28 18:54 UTC (permalink / raw)
To: pgsql-admin
Hi to all,
I configured the log rotation of postgresql started in this way:
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p
/usr/bin/postmaster start > /var/log/postgresql.log 2>&1" < /dev/null
with the log rotate file:
/var/log/postgresql.log {
compress
rotate 5
size=10000k
create 0664 postgres postgres
daily
sharedscripts
copytruncate
}
the problem now is that the postgres server is really
stressed and write continuosly on the log file
and the file is not truncated!!!!!
anyone have any idea??
Ciao
Gaetano
--
#exclude <windows>
#include <CSRSS>
printf("\t\t\b\b\b\b\b\b");.
printf("\t\t\b\b\b\b\b\b");
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Log rotation
@ 2002-04-02 04:54 Andre Schubert <andre.schubert@km3.de>
parent: Gaetano Mendola <mendola@bigfoot.com>
0 siblings, 1 reply; 12+ messages in thread
From: Andre Schubert @ 2002-04-02 04:54 UTC (permalink / raw)
To: Gaetano Mendola <mendola@bigfoot.com>; +Cc: pgsql-admin
Gaetano Mendola schrieb:
>
> Hi to all,
>
> I configured the log rotation of postgresql started in this way:
>
> su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p
> /usr/bin/postmaster start > /var/log/postgresql.log 2>&1" < /dev/null
>
> with the log rotate file:
>
> /var/log/postgresql.log {
> compress
> rotate 5
> size=10000k
> create 0664 postgres postgres
> daily
> sharedscripts
> copytruncate
> }
>
> the problem now is that the postgres server is really
> stressed and write continuosly on the log file
> and the file is not truncated!!!!!
>
> anyone have any idea??
You can use multilog on linux.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Log rotation
@ 2002-04-03 09:20 Gaetano Mendola <mendola@bigfoot.com>
parent: Andre Schubert <andre.schubert@km3.de>
0 siblings, 1 reply; 12+ messages in thread
From: Gaetano Mendola @ 2002-04-03 09:20 UTC (permalink / raw)
To: Andre Schubert <andre.schubert@km3.de>; +Cc: pgsql-admin
"Andre Schubert" <andre.schubert@km3.de> wrote:
> You can use multilog on linux.
Hi, I don't know what's multilog but I resolved my
problem in this way (general suggestions for all):
#File postgresql.conf
syslog = 2
syslog_facility = 'LOCAL0'
syslog_ident = 'postgres'
#File /etc/logrotate.d/postgres
/var/log/postgresql.log {
compress
rotate 5
size=10000k
errors mendola@bigfoot.com
create 0664 postgres postgres
daily
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
#In File syslog.conf
LOCAL0.*
/var/log/postgresql.log
Ciao
Gaetano
--
#exclude <windows>
#include <CSRSS>
printf("\t\t\b\b\b\b\b\b");.
printf("\t\t\b\b\b\b\b\b");
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Log rotation
@ 2002-04-04 10:08 Andre Schubert <andre.schubert@km3.de>
parent: Gaetano Mendola <mendola@bigfoot.com>
0 siblings, 0 replies; 12+ messages in thread
From: Andre Schubert @ 2002-04-04 10:08 UTC (permalink / raw)
To: Gaetano Mendola <mendola@bigfoot.com>; +Cc: pgsql-admin
Gaetano Mendola schrieb:
>
> "Andre Schubert" <andre.schubert@km3.de> wrote:
> > You can use multilog on linux.
>
> Hi, I don't know what's multilog but I resolved my
> problem in this way (general suggestions for all):
multilog does exactly the same as logrotate, but it is a process itself.
we you it this way:
su -l postgres -c "/usr/bin/pg_ctl ....' start 2>&1 | /usr/bin/multilog
s16777215 n20 '/var/log/psql' &" < /dev/null
Everything coming from postgres is piped through multilog and multilog
creates logfiles in the directory
/var/log/pgsql. Each logfile is 16777215 bytes big, and there are max 20
logfiles.
There should be a multilog-rpms somewhere for linux.
Hope this also helps.
Regards
>
> #File postgresql.conf
>
> syslog = 2
> syslog_facility = 'LOCAL0'
> syslog_ident = 'postgres'
>
> #File /etc/logrotate.d/postgres
>
> /var/log/postgresql.log {
> compress
> rotate 5
> size=10000k
> errors mendola@bigfoot.com
> create 0664 postgres postgres
> daily
> postrotate
> /usr/bin/killall -HUP syslogd
> endscript
> }
>
> #In File syslog.conf
> LOCAL0.*
> /var/log/postgresql.log
>
> Ciao
> Gaetano
>
> --
> #exclude <windows>
> #include <CSRSS>
> printf("\t\t\b\b\b\b\b\b");.
> printf("\t\t\b\b\b\b\b\b");
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
^ permalink raw reply [nested|flat] 12+ messages in thread
* Log Rotation
@ 2023-12-12 16:11 SOzcn <selahattinozcnma@gmail.com>
0 siblings, 3 replies; 12+ messages in thread
From: SOzcn @ 2023-12-12 16:11 UTC (permalink / raw)
To: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Hello team I hope everything going well for you guys!
I have a question about log rotation.
I set the parameters as a daily. The set parameters are as follows.
In this case, the log file is created as
"postgresqllogtest-2023-12-12_182351.log" after the 13th day file, the logs
in the 12th day file need to be truncated.
Is the expected result correct? Or does PostgreSQL not support deleting,
truncating files? I got successful results when I did this process hourly.
However, I could not get a correct result when I tried it daily log
truncate.
The parameter for I used as Hour log; postgresql-%H%M
log_destination = 'stderr'
logging_collector = on
log_directory = '/var/log/postgresql/logtest'
log_filename = 'postgresqllogtest-%Y-%m-%d_%H%M%S.log'
log_rotation_age=1440
log_min_duration_statement = 5000
log_line_prefix = 'time=%t [%p]: db=%d,user=%u,app=%a,client=%h '
log_statement = 'none'
log_temp_files = 0
log_timezone = 'Europe/Istanbul'
log_hostname = on
log_min_messages = warning
log_min_error_statement = error
log_lock_waits = on
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Log Rotation
@ 2023-12-12 16:18 Tom Lane <tgl@sss.pgh.pa.us>
parent: SOzcn <selahattinozcnma@gmail.com>
2 siblings, 1 reply; 12+ messages in thread
From: Tom Lane @ 2023-12-12 16:18 UTC (permalink / raw)
To: SOzcn <selahattinozcnma@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>
SOzcn <selahattinozcnma@gmail.com> writes:
> I set the parameters as a daily. The set parameters are as follows.
> In this case, the log file is created as
> "postgresqllogtest-2023-12-12_182351.log" after the 13th day file, the logs
> in the 12th day file need to be truncated.
> Is the expected result correct? Or does PostgreSQL not support deleting,
> truncating files? I got successful results when I did this process hourly.
> However, I could not get a correct result when I tried it daily log
> truncate.
If you want log rotation, you need to choose your filename pattern
so that old log files will be overwritten after a while; or else
set up some external tool for removing the old ones. Postgres does
not do anything to keep track of old log files.
regards, tom lane
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Log Rotation
@ 2023-12-12 16:25 SOzcn <selahattinozcnma@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 12+ messages in thread
From: SOzcn @ 2023-12-12 16:25 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Hello Tom,
Thanks for the response.
On the top you can see the parameters, I already set the parameters as you
said. But the truncate didn't work for daily.
Tom Lane <tgl@sss.pgh.pa.us>, 12 Ara 2023 Sal, 19:18 tarihinde şunu yazdı:
> SOzcn <selahattinozcnma@gmail.com> writes:
> > I set the parameters as a daily. The set parameters are as follows.
>
> > In this case, the log file is created as
> > "postgresqllogtest-2023-12-12_182351.log" after the 13th day file, the
> logs
> > in the 12th day file need to be truncated.
>
> > Is the expected result correct? Or does PostgreSQL not support deleting,
> > truncating files? I got successful results when I did this process
> hourly.
> > However, I could not get a correct result when I tried it daily log
> > truncate.
>
> If you want log rotation, you need to choose your filename pattern
> so that old log files will be overwritten after a while; or else
> set up some external tool for removing the old ones. Postgres does
> not do anything to keep track of old log files.
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Log Rotation
@ 2023-12-12 16:48 Ron Johnson <ronljohnsonjr@gmail.com>
parent: SOzcn <selahattinozcnma@gmail.com>
2 siblings, 1 reply; 12+ messages in thread
From: Ron Johnson @ 2023-12-12 16:48 UTC (permalink / raw)
To: Pgsql-admin <pgsql-admin@lists.postgresql.org>
On Tue, Dec 12, 2023 at 11:11 AM SOzcn <selahattinozcnma@gmail.com> wrote:
> Hello team I hope everything going well for you guys!
>
> I have a question about log rotation.
>
> I set the parameters as a daily. The set parameters are as follows.
>
> In this case, the log file is created as
> "postgresqllogtest-2023-12-12_182351.log" after the 13th day file, the logs
> in the 12th day file need to be truncated.
>
> Is the expected result correct? Or does PostgreSQL not support deleting,
> truncating files? I got successful results when I did this process hourly.
> However, I could not get a correct result when I tried it daily log
> truncate.
>
> The parameter for I used as Hour log; postgresql-%H%M
>
> log_destination = 'stderr'
> logging_collector = on
> log_directory = '/var/log/postgresql/logtest'
> log_filename = 'postgresqllogtest-%Y-%m-%d_%H%M%S.log'
>
%M%S really isn't needed.
> log_rotation_age=1440
>
(Setting that to "1d" is clearer IMO than 1440 minutes.)
It _says_ "rotation", but _means_ "overwrite".
If you want to _delete_ files older than 12 days, you must have an external
process do it: logrotate, or your own shell script that uses find(1).
https://unix.stackexchange.com/questions/459996/deleting-older-log-files
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Log Rotation
@ 2023-12-12 16:52 SOzcn <selahattinozcnma@gmail.com>
parent: Ron Johnson <ronljohnsonjr@gmail.com>
0 siblings, 0 replies; 12+ messages in thread
From: SOzcn @ 2023-12-12 16:52 UTC (permalink / raw)
To: Ron Johnson <ronljohnsonjr@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Thanks for the response Ron!
Have a great week!
Ron Johnson <ronljohnsonjr@gmail.com>, 12 Ara 2023 Sal, 19:48 tarihinde
şunu yazdı:
> On Tue, Dec 12, 2023 at 11:11 AM SOzcn <selahattinozcnma@gmail.com> wrote:
>
>> Hello team I hope everything going well for you guys!
>>
>> I have a question about log rotation.
>>
>> I set the parameters as a daily. The set parameters are as follows.
>>
>> In this case, the log file is created as
>> "postgresqllogtest-2023-12-12_182351.log" after the 13th day file, the logs
>> in the 12th day file need to be truncated.
>>
>> Is the expected result correct? Or does PostgreSQL not support deleting,
>> truncating files? I got successful results when I did this process hourly.
>> However, I could not get a correct result when I tried it daily log
>> truncate.
>>
>> The parameter for I used as Hour log; postgresql-%H%M
>>
>> log_destination = 'stderr'
>> logging_collector = on
>> log_directory = '/var/log/postgresql/logtest'
>> log_filename = 'postgresqllogtest-%Y-%m-%d_%H%M%S.log'
>>
>
> %M%S really isn't needed.
>
>
>> log_rotation_age=1440
>>
>
> (Setting that to "1d" is clearer IMO than 1440 minutes.)
>
> It _says_ "rotation", but _means_ "overwrite".
>
> If you want to _delete_ files older than 12 days, you must have an
> external process do it: logrotate, or your own shell script that uses
> find(1).
> https://unix.stackexchange.com/questions/459996/deleting-older-log-files
>
>
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Log Rotation
@ 2023-12-12 22:48 Laurenz Albe <laurenz.albe@cybertec.at>
parent: SOzcn <selahattinozcnma@gmail.com>
0 siblings, 0 replies; 12+ messages in thread
From: Laurenz Albe @ 2023-12-12 22:48 UTC (permalink / raw)
To: SOzcn <selahattinozcnma@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>
On Tue, 2023-12-12 at 19:25 +0300, SOzcn wrote:
> On the top you can see the parameters, I already set the parameters as
> you said. But the truncate didn't work for daily.
Again: PostgreSQL will only truncate a file if, during log rotation,
it starts writing to a file that already exists.
It does not take care about old, closed log files.
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Log Rotation
@ 2023-12-13 02:13 sagar jadhav <sagarjdhv5@gmail.com>
parent: SOzcn <selahattinozcnma@gmail.com>
2 siblings, 1 reply; 12+ messages in thread
From: sagar jadhav @ 2023-12-13 02:13 UTC (permalink / raw)
To: SOzcn <selahattinozcnma@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Hi,
You can set "log_truncate_on_rotation" to "on" to truncate the log files if
the log file name is same on rotation.
Thanks,
Sagar
On Tue, Dec 12, 2023 at 9:41 PM SOzcn <selahattinozcnma@gmail.com> wrote:
> Hello team I hope everything going well for you guys!
>
> I have a question about log rotation.
>
> I set the parameters as a daily. The set parameters are as follows.
>
> In this case, the log file is created as
> "postgresqllogtest-2023-12-12_182351.log" after the 13th day file, the logs
> in the 12th day file need to be truncated.
>
> Is the expected result correct? Or does PostgreSQL not support deleting,
> truncating files? I got successful results when I did this process hourly.
> However, I could not get a correct result when I tried it daily log
> truncate.
>
> The parameter for I used as Hour log; postgresql-%H%M
>
> log_destination = 'stderr'
> logging_collector = on
> log_directory = '/var/log/postgresql/logtest'
> log_filename = 'postgresqllogtest-%Y-%m-%d_%H%M%S.log'
> log_rotation_age=1440
> log_min_duration_statement = 5000
> log_line_prefix = 'time=%t [%p]: db=%d,user=%u,app=%a,client=%h '
> log_statement = 'none'
> log_temp_files = 0
> log_timezone = 'Europe/Istanbul'
> log_hostname = on
> log_min_messages = warning
> log_min_error_statement = error
> log_lock_waits = on
>
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Log Rotation
@ 2023-12-13 07:25 SOzcn <selahattinozcnma@gmail.com>
parent: sagar jadhav <sagarjdhv5@gmail.com>
0 siblings, 0 replies; 12+ messages in thread
From: SOzcn @ 2023-12-13 07:25 UTC (permalink / raw)
To: sagar jadhav <sagarjdhv5@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Thanks for the response guys, yeah that works with the specific log file.
Have a nice day!
sagar jadhav <sagarjdhv5@gmail.com>, 13 Ara 2023 Çar, 05:13 tarihinde şunu
yazdı:
> Hi,
> You can set "log_truncate_on_rotation" to "on" to truncate the log files
> if the log file name is same on rotation.
>
> Thanks,
> Sagar
>
> On Tue, Dec 12, 2023 at 9:41 PM SOzcn <selahattinozcnma@gmail.com> wrote:
>
>> Hello team I hope everything going well for you guys!
>>
>> I have a question about log rotation.
>>
>> I set the parameters as a daily. The set parameters are as follows.
>>
>> In this case, the log file is created as
>> "postgresqllogtest-2023-12-12_182351.log" after the 13th day file, the logs
>> in the 12th day file need to be truncated.
>>
>> Is the expected result correct? Or does PostgreSQL not support deleting,
>> truncating files? I got successful results when I did this process hourly.
>> However, I could not get a correct result when I tried it daily log
>> truncate.
>>
>> The parameter for I used as Hour log; postgresql-%H%M
>>
>> log_destination = 'stderr'
>> logging_collector = on
>> log_directory = '/var/log/postgresql/logtest'
>> log_filename = 'postgresqllogtest-%Y-%m-%d_%H%M%S.log'
>> log_rotation_age=1440
>> log_min_duration_statement = 5000
>> log_line_prefix = 'time=%t [%p]: db=%d,user=%u,app=%a,client=%h '
>> log_statement = 'none'
>> log_temp_files = 0
>> log_timezone = 'Europe/Istanbul'
>> log_hostname = on
>> log_min_messages = warning
>> log_min_error_statement = error
>> log_lock_waits = on
>>
>
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2023-12-13 07:25 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-28 18:54 Log rotation Gaetano Mendola <mendola@bigfoot.com>
2002-04-02 04:54 ` Andre Schubert <andre.schubert@km3.de>
2002-04-03 09:20 ` Gaetano Mendola <mendola@bigfoot.com>
2002-04-04 10:08 ` Andre Schubert <andre.schubert@km3.de>
2023-12-12 16:11 Log Rotation SOzcn <selahattinozcnma@gmail.com>
2023-12-12 16:18 ` Re: Log Rotation Tom Lane <tgl@sss.pgh.pa.us>
2023-12-12 16:25 ` Re: Log Rotation SOzcn <selahattinozcnma@gmail.com>
2023-12-12 22:48 ` Re: Log Rotation Laurenz Albe <laurenz.albe@cybertec.at>
2023-12-12 16:48 ` Re: Log Rotation Ron Johnson <ronljohnsonjr@gmail.com>
2023-12-12 16:52 ` Re: Log Rotation SOzcn <selahattinozcnma@gmail.com>
2023-12-13 02:13 ` Re: Log Rotation sagar jadhav <sagarjdhv5@gmail.com>
2023-12-13 07:25 ` Re: Log Rotation SOzcn <selahattinozcnma@gmail.com>
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