In Perl you can:
print STDERR "bla bla bla";
...and Apache will dump it to /etc/httpd/logs/error_log.
But what if I want to send some error/warning messages to a different log file?
How can I create a function to do this in Perl?
print MYLOGFILE "bla bla bla"
...to render to /logs/my_favorite_log?
You should probably take a look at some of the formal logging packages for Perl, like log4perl. Undoubtedly, there are others as well.
Use Log::Trivial
use Log::Trivial;
my $logfile = Log::Trivial->new(log_file => "logs/my_favourite.log");
$logfile->set_level(3);
$logfile->write(comment => "bla bla bla");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With