Connecting Tech Pros Worldwide Forums | Help | Site Map

A simple example of log

Member
 
Join Date: Jul 2008
Posts: 70
#1: Aug 8 '08
I am trying to write a log file and saw an eaxmple as below. The example forks and I don't need to do. I jsut want to open a log file and try to add into the log file and try with count parameter alone. Or do I have to use
Expand|Select|Wrap|Line Numbers
  1. Signal
for rotating. Please give me a small example. Thanks.

Expand|Select|Wrap|Line Numbers
  1. use Logfile::Rotate;
  2. $logfile = new Logfile::Rotate(
  3.                 File   => "/var/adm/log/syslog",
  4.                 Count  => 5,
  5.  
  6.                 Signal => 
  7.                    sub {
  8.                         open PID, "/etc/syslog.pid" or
  9.                            die "Unable to open pid file:$!\n";
  10.                         chomp($pid = <PID>);
  11.                         close PID;
  12.                         # should check validity first
  13.                         kill 'HUP', $pid; 
  14.                         }
  15.             );

pawanrpandey's Avatar
Newbie
 
Join Date: Feb 2007
Location: Bangalore
Posts: 11
#2: Aug 8 '08

re: A simple example of log


Could you please explain your requirement clearly? It is not very clear from your statements and provided code. If you can write in steps like:
Expand|Select|Wrap|Line Numbers
  1. Have a program doing something
  2. Want to print all activity of that program in a Log file
  3. Any specific operation I want to do
  4. Close the log file
etc...

Regards,
Pawan
Reply