Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hello ibm1620,

As was already mentioned, I use the *nix 'syslog' in production. But since you're in development mode at the present time, I suggest you use a unique log file for each 'fork'ed child.

use Sys::Syslog qw(:DEFAULT setlogsock) our ( $LOG, $Debug, $start ); $Debug = 4; ## I use 0 for production, and 1..9 for tes +ting our $NAME = "$prog-$Debug"; ## $prog should be a name to help y +ou setlogsock('unix'); openlog(" $$ Srv", 'ndelay', 'localn'); ## 'n' is defined by s +ystem admin syslog('info', "############# Starting #############"); . . . if ( $Debug == 0 ) ## This is production { open ($LOG, ">","/dev/null") || Die_RTN("$NAME: Not open-8 /d +ev/null"); } else ## This will log for levels 1..9 { open ($LOG, ">","./logs/Child$$") || Die_RTN("$NAME: Not open +-9 Child$$"); my $time = time; $start = 0; print $LOG "Info: |$time|$start|\n"; } $start++; if ( $Debug >= 4 ) ## This is for level 4 or greater debug in +formation { my $ctime = time; print $LOG "Info: |$ctime|$start|\n"; } . . . closelog(); close $LOG;

This allows you to see what logs are generated for the production environment, and also allows you to have very detailed debugging information during development. Once code is working correctly, you can make the test for a higher number and eliminate unneeded data from the child logs.

I open the 'syslog' before forking the children, and then open the debugging logs in the children. The '$$' is the unique process ID of the child.

Hope this helps and that I typed everything correctly :-)

Good Luck...Ed

"Well done is better than well said." - Benjamin Franklin


In reply to Re: Having several processes share a logfile by flexvault
in thread Having several processes share a logfile by ibm1620

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (6)
    As of 2018-07-19 17:43 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















      Results (413 votes). Check out past polls.

      Notices?