Limiting the no. of logs file generated by postgreSQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

I am currently using PostgreSQL 9.4.5. 

In one scenario with heavy traffic, log file size increased to 100GB in a day, and due to which system ran out of disk space. The configuration in postgresql.conf for log file was:

log_filename = 'postgresql-%a.log'

So, I want the log files to rotate such that the, 
1. Total size of the Postgres logs is always less than 700MB.
2. I want to maintain recent 5 log files of 20MB each in a day .i.e. Total 100MB/day. 

So I have tried only log_rotation_size option as below in configuration file, but it didn't work for me.

log_rotation_size = '10kB' /* The file is not rotated after size increases over 10KB. */

When I tried logging with the following configuration (just to test, the values are pretty low):

log_rotation_size = '10kB'
log_filename = 'postgresql-%Y-%m-%d_%M.log'
log_truncate_on_rotation = 'on'
log_rotation_age = '10'

What I've observed is, 
1. I get a new file after every 10 Mins or when I restart the service or logs size is over 10KB. 

But, it doesn't solve my problem to reduce the size of postgres logs, as the file is not rotated, but a new is created every time.

Is there any way I can rotate the files or restrict number to, say max 5 files
like,
postgresql-Mon-1.log
postgresql-Mon-2.log
postgresql-Mon-3.log
postgresql-Mon-4.log
postgresql-Mon-5.log

and then re-write to "postgresql-Mon-1.log" file.

Regards,
Merina

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux