diff --git a/lib/RT.pm.in b/lib/RT.pm.in index 2467eda..8f8e0d1 100755 --- a/lib/RT.pm.in +++ b/lib/RT.pm.in @@ -284,17 +284,25 @@ sub InitLogging { }; if ( $Config->Get('LogToFile') ) { - my ($filename, $logdir) = ( - $Config->Get('LogToFileNamed') || 'rt.log', - $Config->Get('LogDir') || File::Spec->catdir( $VarPath, 'log' ), - ); - if ( $filename =~ m![/\\]! ) { # looks like an absolute path. - ($logdir) = $filename =~ m{^(.*[/\\])}; - } - else { - $filename = File::Spec->catfile( $logdir, $filename ); + + # The installer can specify name of log file using the + # LogToFileNamed option. This filename is relative to the + # directory specified by the LogDir option. + + my $filename = $Config->Get('LogToFileNamed') || 'rt.log'; + if ( not File::Spec->file_name_is_absolute($filename) ) { + + # And the "LogDir" option is relative to $BasePath. + + my $logdir = $Config->Get('LogDir') + || File::Spec->catdir( $VarPath, 'log' ); + if ( not File::Spec->file_name_is_absolute($logdir) ) { + $logdir = File::Spec->catdir( $BasePath, $logdir ); + } + $filename = File::Spec->catdir( $logdir, $filename ); } + my ($logdir) = $filename =~ m{^(.*[/\\])}; unless ( -d $logdir && ( ( -f $filename && -w $filename ) || -w $logdir ) ) { # localizing here would be hard when we don't have a current user yet die "Log file '$filename' couldn't be written or created.\n RT can't run.";