From 5f04e163f3f528b52d812448972e56cf5b9ed52d Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 26 Aug 2020 00:58:36 +0000 Subject: [PATCH] Bug 16357: Only use Log4perl middleware if appenders defined This patch checks that the loggers used by the middleware actually have appenders defined. Without this patch, if the loggers don't have appenders defined in the log4perl file, the logs will just be lost. --- debian/templates/plack.psgi | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/debian/templates/plack.psgi b/debian/templates/plack.psgi index 7bfb34fb68..99438c595a 100644 --- a/debian/templates/plack.psgi +++ b/debian/templates/plack.psgi @@ -38,6 +38,7 @@ use Koha::Database; use Koha::DateUtils; use Koha::Logger; +use Log::Log4perl; use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise { no warnings 'redefine'; @@ -77,18 +78,24 @@ builder { enable "+Koha::Middleware::RealIP"; mount '/opac' => builder { - enable 'Log4perl', category => 'plack-opac'; - enable 'LogWarn'; + if ( Log::Log4perl->get_logger('plack-opac')->has_appenders ){ + enable 'Log4perl', category => 'plack-opac'; + enable 'LogWarn'; + } $opac; }; mount '/intranet' => builder { - enable 'Log4perl', category => 'plack-intranet'; - enable 'LogWarn'; + if ( Log::Log4perl->get_logger('plack-intranet')->has_appenders ){ + enable 'Log4perl', category => 'plack-intranet'; + enable 'LogWarn'; + } $intranet; }; mount '/api/v1/app.pl' => builder { - enable 'Log4perl', category => 'plack-api'; - enable 'LogWarn'; + if ( Log::Log4perl->get_logger('plack-api')->has_appenders ){ + enable 'Log4perl', category => 'plack-api'; + enable 'LogWarn'; + } $apiv1; }; }; -- 2.11.0