I created a customized log file which contains information as I want it to get into the log file. Some example can be seen below.

WriteLog("PROJECTCONTROL","INFO",'ID1252',"Project Name is \<$project_ +name\>"); WriteLog("PROJECTCONTROL","INFO",'ID1250',"Datasource of this job was +\<$datasources\>"); sub WriteLog { my ($script,$type,$id,$log) = @_; $logfile = $job_path.'/user/LogFile.txt'; my $logdate = $today; my $loguser = $USERNAME; open (LOG, ">>$logfile") || die "File does not exist\n"; print LOG "$script $type $id $loguser $logdate $log\n"; close (LOG); }

This works very nice and I can now from the log file know what exactly is happening and where something is in the process and which script is running and if something failed upto which point something had ran fine. However in case something fails what I will not get into this file is the failure message which will be returned by Perl, or an application or anything else, which is mostly returned to the STDOUT screen. So I see they are some modules maybe available to do this but I would like to stick to my customized log file and just would like to add the warning and errors which would be provided by Perl itself to it. I don't know if this is possible in an easy way.


In reply to Re^2: Creating a comprehensive log file by juo
in thread Creating a comprehensive log file by juo

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, details, 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, summary, 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.