Bug 16509

Summary: Koha::Logger dies when log4perl.conf has FileAppender files with different owners, also compatibility with logrotate
Product: Koha Reporter: Olli-Antti Kivilahti <olli-antti.kivilahti>
Component: Architecture, internals, and plumbingAssignee: Olli-Antti Kivilahti <olli-antti.kivilahti>
Status: CLOSED INVALID QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: david, jonathan.druart, kyle, martin.renvoize, mirko, tomascohen
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 14167    
Bug Blocks:    
Attachments: Bug-16509-Koha-Logger-dies-when-log4perl.conf-has-Fi.patch
Bug 16509: fix multi-owner perms, improve logrotate compatibility

Description Olli-Antti Kivilahti 2016-05-12 16:39:15 UTC
We define all the logging configurations for various interfaces in log4perl.conf.
Interfaces log to files, and every interface can run as a different user.
Every time you execute a Perl program that uses Koha::Logger and Log::Log4perl, Log::Log4perl tries to open all the filehandles in the log4perl.conf.

Since different interface logs should be owned by different users, this crashes the system.

Can't sysopen /home/koha/koha-dev/var/log/intranet.log (Permission denied) at /usr/local/share/perl/5.18.2/Log/Log4perl/Appender/File.pm line 120.


This patch introduces lazy-loading parameters to the FileAppenders, so they open only the files they need. Koha::Logger makes sure they always use the correct log file for the interface (opac, intranet, commandline, sip, restapi, ...).
log4perl.appender.CLI.syswrite=true
log4perl.appender.*.create_at_logtime=true



Also while working on this bug identified as a target of opportunity some useful extra parameters for the appenders.


log4perl.appender.*.syswrite=true

This should solve concurrency issues under multithreaded Perl-apps such as what Mojolicious should be ran as.


log4perl.appender.*.recreate=true

This polls the filesystem path to the logfile for changes. Eg. if logrotate of the admin might move the logfile for storage purposes, Log4perl can recreate the missing file, instead of writing to the moved file.
Comment 1 Olli-Antti Kivilahti 2016-05-12 16:58:20 UTC
Created attachment 51458 [details] [review]
Bug-16509-Koha-Logger-dies-when-log4perl.conf-has-Fi.patch
Comment 2 Kyle M Hall (khall) 2016-05-13 12:41:39 UTC
Olli, this patch doesn't apply to master. I think this must be dependent on another bug.
Comment 3 Mark Tompsett 2019-06-24 13:10:17 UTC
Created attachment 90944 [details] [review]
Bug 16509: fix multi-owner perms, improve logrotate compatibility

Rescued, because the last CLI section no longer exists.
Comment 4 David Nind 2020-02-17 08:26:48 UTC
The patch still applies, but how can I test this?
Comment 5 Jonathan Druart 2020-04-21 10:31:49 UTC
In which case do we have such situations?

I am marking this as INVALID for now, as to me we should not face it with our current infrastructure.

Please reopen with more details if you think it's still valid.