Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^2: log file in Log4perl

by palette (Scribe)
on Jan 12, 2007 at 11:57 UTC ( #594361=note: print w/replies, xml ) Need Help??

in reply to Re: log file in Log4perl
in thread log file in Log4perl


Can I know why a "\" is required at the end of every line of the sub. As per the CPAN description it seems that we have to send reference of the method. If wrong do correct me.


Replies are listed 'Best First'.
Re^3: log file in Log4perl
by ferreira (Chaplain) on Jan 12, 2007 at 12:07 UTC

    In the piece of code you mentioned, you are not writing Perl code but a properties file (with lines "key = value") which is read by this statement:


    The value can be extended for many lines if they end in "\". There is more info in the FAQ within Log-Log4perl distribution.

Re^3: log file in Log4perl
by jasonk (Parson) on Jan 12, 2007 at 14:23 UTC

    Because the Log4perl configuration file format requires each configuration item to be on a single line. You can continue a line onto the next line by ending it in a backslash, or you can just type it out as one really long line. If you review the documentation on CPAN again, you will notice that all of the examples use very short subs, and none of them span more than one line.

    The method I normally use for approaching this is something like...

    # config file log4perl.logger.ClassA = DEBUG, ClassA log4perl.appender.ClassA = Log::Log4perl::Appender::File log4perl.appender.ClassA.filename = sub { log_filename() } # in the main code use POSIX 'strftime'; sub log_filename { return strftime( "/tmp/ClassA%Y%m%d.log", localtime ); } Log::Log4perl::init_and_watch('/etc/log4perl.conf',5); my $mylog = Log::Log4perl->get_logger();

    We're not surrounded, we're in a target-rich environment!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://594361]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2023-06-08 04:26 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.