Logging, Syslog and Log Anaylsys Forums
July 30, 2010, 09:36:53 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
   Home   WIKI BLOG Help Search Recent Topics GoogleTagged Login Register  
Pages: [1]
  Print  
Author Topic: Rotating log file specified in log source  (Read 2573 times)
kalkotivinay
Newbie
*
Offline Offline

Posts: 32


View Profile Email
« on: May 12, 2009, 12:16:48 pm »


Hi,

I have a program which reads logs from the unixstream(). Syslog-ng reads logs from a file and send them to this unixstream.

So, I have added the log file in the source{} and unixstream in the destination{}.

As time goes, the log file is getting bigger and the plan to is rotate it. How should I make sure that syslog-ng reads all the events from this file before the file is rotated ?.

Thanks,
Vinay
Logged
mutex
Administrator
Newbie
*****
Offline Offline

Posts: 901


View Profile
« Reply #1 on: May 12, 2009, 07:26:44 pm »

Is your concern that when you send a HUP signal to syslog-ng that it'll lose data if there is stuff in the stream waiting to be read?  I think it will block until it's read.
Logged
kalkotivinay
Newbie
*
Offline Offline

Posts: 32


View Profile Email
« Reply #2 on: May 13, 2009, 03:44:16 am »


I have fixed the HUP signal issue. The problem was in my code. It was nothing related to syslog-ng.

I have a situation where syslog-ng is reading from a file (myprocess.log) and writing the events to the unixstream. Another process is reading the events from the unixstream.

The process which writes to myprocess.log is a daemon. So, the plan is to logrotate the myprocess.log file. Since syslog-ng is reading events from the myprocess.log file, my concern is that syslog-ng might miss reading some events when the myprocess.log is rotated.

My question is will I run into this problem and is there a solution for this ?
Logged
mutex
Administrator
Newbie
*****
Offline Offline

Posts: 901


View Profile
« Reply #3 on: May 13, 2009, 11:24:01 am »

I understand now.  That's a good question.  How are you reading the logs with syslog-ng?  using the source file() directive? 
Logged
kalkotivinay
Newbie
*
Offline Offline

Posts: 32


View Profile Email
« Reply #4 on: May 13, 2009, 11:58:07 am »

my source looks like this -->
source unixstream_src { file("/var/log/myprocess.log" follow_freq(1) flags(no-parse)); };
Logged
Admin
Administrator
Newbie
*****
Offline Offline

Posts: 146


View Profile WWW
« Reply #5 on: May 13, 2009, 04:52:42 pm »

I suspect it could happen.  Do you have follow_freq(1) set for a reason?  I think it's much less likely to happen without follow_freq(1), but then if you have it set for a specific reason, it's a moot point.

The other way to do this, though it's a bit of a hack, is this:
Code:
tail -f /var/log/myprocess.log | logger -h localhost
Of course, you would have to set up syslog-ng to listen on the network, and handle restarting the tail after a log rotate, unless you copy the log, then clear - something like this:

Code:
cp /var/log/myprocess.log /var/log/myprocess.log.0
echo '' >/var/log/myprocess.log
Logged
kalkotivinay
Newbie
*
Offline Offline

Posts: 32


View Profile Email
« Reply #6 on: May 14, 2009, 05:28:50 am »


The reason why I have specified follow_freq(1) is that on syslog-ng startup,  /var/log/myprocess.log file might not be created and when syslog-ng starts, it throw an error. So, I have specified the follow_freq(1).
Logged
Admin
Administrator
Newbie
*****
Offline Offline

Posts: 146


View Profile WWW
« Reply #7 on: May 14, 2009, 10:49:16 am »

Ok.  I am not certain of the polling interval when follow_freq is on.  I think you are right to be concerned about losing logs.  If it is critical that you don't miss any logs, you may have to resort to something like the tail suggestion above. 
Logged
Pages: [1]
  Print  

 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC | Sitemap Valid XHTML 1.0! Valid CSS!