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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.