From e9040dc6389080d9f8a72180207c4b3f96458a3e Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Wed, 21 Mar 2018 09:19:44 +0200
Subject: [PATCH] Fix LoggerFactory to handle a Windows path with drive letter
 properly.

---
 module/VuFind/src/VuFind/Log/LoggerFactory.php | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/module/VuFind/src/VuFind/Log/LoggerFactory.php b/module/VuFind/src/VuFind/Log/LoggerFactory.php
index bcc6d393dd7..807a04a4649 100644
--- a/module/VuFind/src/VuFind/Log/LoggerFactory.php
+++ b/module/VuFind/src/VuFind/Log/LoggerFactory.php
@@ -116,9 +116,16 @@ class LoggerFactory implements \Zend\ServiceManager\FactoryInterface
      */
     protected function addFileWriters(Logger $logger, $config)
     {
-        $parts = explode(':', $config);
-        $file = $parts[0];
-        $error_types = isset($parts[1]) ? $parts[1] : '';
+        // Make sure to use only the last ':' after second character to avoid trouble
+        // with Windows drive letters (e.g. "c:\something\logfile:error-5")
+        $pos = strrpos($config, ':', 2);
+        if ($pos > 0) {
+            $file = substr($config, 0, $pos);
+            $error_types = substr($config, $pos + 1);
+        } else {
+            $file = $config;
+            $error_types = '';
+        }
 
         // Make Writers
         $filters = explode(',', $error_types);
-- 
GitLab