hi monks,
i am trying to set up a logging implementation which
logs WARN messages to one log and INFO messages to another log whose filename should be dynamically generated from the month which is ongoing
here is my attempt
log4perl.rootLogger=INFO,LOGFILE
log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=/var/log/myerrs.log
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.layout=PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern=%d [%l] %p %c - %m%
+n
log4perl.Logger.newpingdata=INFO,LOG
log4perl.appender.LOG=Log::Log4perl::Appender::File
log4perl.appender.LOG.filename=/var/log/errs.log
log4perl.appender.LOG.mode=append
log4perl.appender.LOG.layout=PatternLayout
log4perl.appender.LOG.layout.ConversionPattern=%d [%l] %p %c - %m%n
# tried this above to dynamicaaly generate filename
log4perl.appender.LOG.filename = sub { my @curr=`date`;my
+($day,$month,$date,$time,$std,$year) = split (/\s+/,$curr[0]);chomp $
+month; return "/var/log/myerrs.$month.log"}
I use this for logging
my $log -> Log::Log4perl->get_logger();
$log->warn("hi");
my $log -> Log::Log4perl->get_logger("newpingdata");
$log->info("down");
but both hi and down get logged in the same file (/var/log/myerrs.log)
+????
any suggestions.
regards
chimni
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.