Rolling file log

153 views
Skip to first unread message

deni

unread,
Feb 20, 2012, 12:09:25 PM2/20/12
to Log.io
If I have a log file that's named like this: YYYY_MM_DD_logfile.log
how would i go about writing the config file for the harverster to
track that file?



-Deni

deni

unread,
Feb 21, 2012, 6:06:06 AM2/21/12
to Log.io
OK I figured out it's simple enough to just to prepend the date in the
desired format to the file name.
The conf file is just javascript that's being excuted so I put this
in:

var dateFormat = require('./date.format.js');
var now = new Date();
var pre = now.format("yyyy_mm_dd");

and prepended that to the file name string:

log_file_paths: {
jetty: '/opt/jetty/logs/'+pre+'.stderrout.log'
},

But the problem with approach is that the conf file is loaded during
startup and it will watch the correct file but once the date changes
and the lof file rolls over it will continue watching the old file and
not refresh.
I have yet to figure out how to get it to watch for rolling log files.


-Deni

ideahelper

unread,
Aug 29, 2012, 12:37:02 PM8/29/12
to lo...@googlegroups.com
Hey Deni,

Can you explain where you added the javascript? Also, is this a file you created date.format.js (var dateFormat = require('./date.format.js');  )?

I am looking to pull logs from my directory for example:

/var/www/app_logs/

App-Layer-Log-20120829.log
App-Layer-Log-20120830.log 
App-Layer-Log-20120831.log  

Thanks

Deni Bertović

unread,
Aug 29, 2012, 3:30:08 PM8/29/12
to lo...@googlegroups.com
Hi Evan,

The code i posted in the previous mail is basically most of my harvester.conf file. So it goes in /etc/log.io/harvester.conf.


and it's basically just a helper lib that's makes it easier to work with dates. I've decided to use it instead of writing the javascript myself beacuse it was...well.... easier. :D
The harvester.conf file is just plain ol' javascript so you can put anything in there that you wan't as long as it's standard javascript, meaning that's it runs without errors.

As i mentioned in the previous email, though, this will not catch the new file descriptor once the log switches so basically you should schedule a cron job to restart the harvester. This is just a very very basic hack. I'm not aware if log.io has "built in" support for rollover logs in the new version (i haven't checked)

-Deni

ideahelper

unread,
Aug 30, 2012, 3:30:29 PM8/30/12
to lo...@googlegroups.com
Hey Deni,

That makes sense and it all worked perfect for what I needed. Thank you!
Reply all
Reply to author
Forward
0 new messages