I am trying to create a separate log file for a application in Linux. So far I have created a .conf script to separate log in custom log file based on program name and it's working correctly.
But, I want to limit the size of log file at 10K and I am using $outchannel for this purpose. The script is stored as /etc/rsyslog.d/00-abc_log.conf:
$outchannel o_abc, /var/log/abc.log, 10240, /home/xyz/logrot
if $programname == 'abc' then :omfile:$o_abc
and script /home/xyz/logrot contains the following:
mv -f /var/log/abc.log /var/log/abc.log.1
Below the 10K limit the logging is working correctly, but after log exceeds 10K size limit, file abc.log.1 doesn't generated and logging in abc.log stops.
If it matters, my system is Xubuntu 12.04 running rsyslog-5.8.6.
Thanks in advance.
logrotateand rather writing your own implementation of log rotation? – gertvdijk Dec 17 '12 at 13:10/etc/logrotate.d/but specify a path yourself to your own config file. Anyway, I suspect your original problem occurs because your application still has a file descriptor open to the other file. Just use Logrotate with itscopytruncateoption to not move the file, but rather copy-and-truncate it. – gertvdijk Dec 18 '12 at 8:55