Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: log file in Log4perl

by Anonymous Monk
on Jan 12, 2007 at 11:39 UTC ( [id://594353]=note: print w/replies, xml ) Need Help??


in reply to log file in Log4perl

Aren't you missing \ at the end of every line of your sub?

Replies are listed 'Best First'.
Re^2: log file in Log4perl
by palette (Scribe) on Jan 12, 2007 at 11:57 UTC
    Hi,

    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.

    Thanks

      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:

      Log::Log4perl::init_and_watch('/etc/log4perl.conf',5);

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

      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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-18 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found