Bug 16509 - Koha::Logger dies when log4perl.conf has FileAppender files with different owners, also compatibility with logrotate
Summary: Koha::Logger dies when log4perl.conf has FileAppender files with different ow...
Status: CLOSED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Olli-Antti Kivilahti
QA Contact: Testopia
URL:
Keywords:
Depends on: 14167
Blocks:
  Show dependency treegraph
 
Reported: 2016-05-12 16:39 UTC by Olli-Antti Kivilahti
Modified: 2020-11-30 21:45 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug-16509-Koha-Logger-dies-when-log4perl.conf-has-Fi.patch (3.41 KB, patch)
2016-05-12 16:58 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review
Bug 16509: fix multi-owner perms, improve logrotate compatibility (1.42 KB, patch)
2019-06-24 13:10 UTC, Mark Tompsett
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 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.