Saturday, 7 January 2017

Simplest way to create a log file with Date and Time using PERL

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.

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.

No comments:

Post a Comment

Hyperlinks are not allowed in comments, Spam/advertising comments will NEVER BE TOLERATED and will be deleted immediately!

Thanks for visiting our website,Bookmark us for more updates.

Contact us


Email *

Message *