Results 1 to 1 of 1
Thread: Logger for Perl
Apr 21, 2009, 06:27 #1
- Join Date
- Apr 2005
- Belfast, North of Ireland
- 0 Post(s)
- 0 Thread(s)
Logger for Perl
Decided that I should go ahead and create some comprehensive logging throughout my application and decided that printing to a file and console was using print methods was a little bit too messy.
What I have been trying to do is this:
$log_dir = "C:\perl_script\logs";
Create a file "$log_dir\file_name_$date.log" where $date would be 20090421 (Todays date) so the entire name would be file_name_20090421.log
On top of this I have been creating custom string messages when logging like so:
open (logfile, ">$logfile") || die("\n can't open $logfile: $!\n"); print logfile time() . " | INFO | Script has started successfully... \n"; print logfile time() . " | INFO | Script has finished running. \n"; close logfile;
2009/4/21 14:27:57 | INFO | Script has started successfully... 2009/4/21 14:27:57 | INFO | Script has started finished.
This all works fine for me, but when looking over my program I find it incredibly messy due to the log strings that I have to use for both console and file. I have seen Log4perl but it doesn't appear to allow customer patterned logging. I am looking for a more simplistic and elegant solution, but even log4perl seems a tad messy too. Unless I've missed something that it offers...? Do any of you guys have any good experience with perl logging API's?
Would you guys have any idea on the best approach to this situation?
MCInnovative Design and Development Services
Design: XHTML - CSS - Photoshop CS - Flash 7 - Illustrator