I'd like to be able to change the log file location at runtime. Here's the details of my failed attempt:
Log invocation:
Code: Select all
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'info',
Message => 'Hello',
LogFile => '/var/log/nginx/otrs/otrs.audit.log'
);
Code: Select all
(...)
my $LogFile = ($Param{LogFile}) ? $Param{LogFile} : $Self->{LogFile};
# open logfile
## no critic
if ( !open $FH, '>>', $LogFile ) {
## use critic
# print error screen
print STDERR "\n";
print STDERR " >> Can't write $LogFile: $! <<\n";
print STDERR "\n";
return;
}
# write log file
$Kernel::OM->Get('Kernel::System::Encode')->SetIO($FH);
print $FH '[' . localtime() . ']'; ## no critic
print $FH "[Info][$Param{Module}] $Param{LogFile}\n";
(...)
Thank you