From 368fa77a0c6053aa9ca528dded81a1b18f60b7f7 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 | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/debian/templates/plack.psgi b/debian/templates/plack.psgi index 7bfb34fb68..9fb20990dc 100644 --- a/debian/templates/plack.psgi +++ b/debian/templates/plack.psgi @@ -77,18 +77,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