Hi, today em gonna show the simplest way to create log files and add date and time to it so that we can know which event occurred at what point of time. So lets begin.
my $now = strftime(‘%d-%m-%Y %H:%M:%S’,localtime);
This is the simplest way to create a Logger file in Perl. Hope you all enjoyed the post. Do like and Share for more.
Fetching and Storing Date and Time :
use POSIX qw(strftime);my $now = strftime(‘%d-%m-%Y %H:%M:%S’,localtime);
Creating Log File :
open ($Log,”+>>”,”/home/amar/MyApplication.log”);
Printing contents to Log File :
print $Log (“$now ******[START OF SCRIPT : DATABASE CHECK]*******\n”);Full Script :
This is the simplest way to create a Logger file in Perl. Hope you all enjoyed the post. Do like and Share for more.
Comments
Post a Comment