[SOLVED] How to change log file location at runtime?

English! place to talk about development, programming and coding
Post Reply
epferreira
Znuny newbie
Posts: 24
Joined: 23 Jun 2016, 15:49
Znuny Version: 4.0.1

[SOLVED] How to change log file location at runtime?

Post by epferreira »

Hello

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'
);
Changes in {OTRS_HOME}/Kernel/System/Log/File.pm, Log function

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";

(...)
Can somebody help me and explain why is $Param{LogFile} empty?

Thank you
Last edited by epferreira on 17 Mar 2017, 10:16, edited 1 time in total.
epferreira
Znuny newbie
Posts: 24
Joined: 23 Jun 2016, 15:49
Znuny Version: 4.0.1

Re: How to change log file location at runtime?

Post by epferreira »

I found it out file.pm implemnts the Log interface, and that's where you define the valid parameters.
Post Reply