Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Custom cspec's in Net::Log4perl

by jimbojones (Friar)
on Apr 21, 2005 at 20:34 UTC ( #450196=note: print w/ replies, xml ) Need Help??

in reply to Custom cspec's in Net::Log4perl


I'm not too sure about this, since I'm not famaliar with Log4Perl ...

isn't $session in your main package? If so, try

log4perl.PatternLayout.cspec.s = sub {return $::session->id}

Comment on Re: Custom cspec's in Net::Log4perl
Select or Download Code
Replies are listed 'Best First'.
Re^2: Custom cspec's in Net::Log4perl
by jpfarmer (Pilgrim) on Apr 21, 2005 at 21:49 UTC

    I tried that, and it silenced strict's complaint, but it now gives Can't call method "id" on an undefined value at (eval 36) line 1.. So, apparently the value still isn't avalible to the module.


      Sorry, I didn't read your code carefully enough.

      # Check to see if we have a session. If so, load it's information. # If not, we need to create one and then cookie the user. #### JJ comment #### 'my' makes this lexically scoped #### change to 'our' or $::session to be visible #### in other scopes my $session = new CGI::Session("driver:DB_File", $cgi, {Directory=>'/u +sr/local/apache/htdocs/addressbook'}); # Init the logger Log::Log4perl->init("/usr/local/apache/htdocs/addressbook/log4perl.con +f");
      you need to change my $session to something package scoped, like $::session. Then, it's somewhat of a global variable, so be carefull.

      - j

        Excellent! It works now!

        Thank you very much for your help!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2015-11-27 00:51 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (710 votes), past polls