Author: grobmeier
Date: Tue Feb 15 20:38:43 2011
New Revision: 1071041

URL: http://svn.apache.org/viewvc?rev=1071041&view=rev
Log:
LOG4PHP-126: LoggerConfiguratorPhp didn't respect appender file property from 
phpconfig. Thanks for the patch to Peter Chapman. Added a unit test.

Modified:
    logging/log4php/trunk/src/changes/changes.xml
    logging/log4php/trunk/src/main/php/configurators/LoggerConfiguratorPhp.php
    
logging/log4php/trunk/src/test/php/configurators/LoggerConfiguratorPhpTest.php

Modified: logging/log4php/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/logging/log4php/trunk/src/changes/changes.xml?rev=1071041&r1=1071040&r2=1071041&view=diff
==============================================================================
--- logging/log4php/trunk/src/changes/changes.xml (original)
+++ logging/log4php/trunk/src/changes/changes.xml Tue Feb 15 20:38:43 2011
@@ -24,6 +24,7 @@
   </properties>
   <body>
        <release version="2.1" description="Stabilizing">
+               <action type="fix" issue="LOG4PHP-126" by="Peter Chapman, 
Christian Grobmeier">LoggerConfiguratorPhp does not appear to respect appender 
file property from config</action>
                <action type="fix" issue="LOG4PHP-118" by="Craig 
Marvelley">Additivity cannot be disabled through log4php.properties ini 
file.</action>
                <action type="update" issue="LOG4PHP-110" by="Vladimir Gorej, 
Christian Grobmeier">Added MongoDB appender</action>
                <action type="fix" issue="LOG4PHP-131" by="Ivan Habunek">File 
appenders parameters (removed overloading of setFile()).</action>

Modified: 
logging/log4php/trunk/src/main/php/configurators/LoggerConfiguratorPhp.php
URL: 
http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/configurators/LoggerConfiguratorPhp.php?rev=1071041&r1=1071040&r2=1071041&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/configurators/LoggerConfiguratorPhp.php 
(original)
+++ logging/log4php/trunk/src/main/php/configurators/LoggerConfiguratorPhp.php 
Tue Feb 15 20:38:43 2011
@@ -80,6 +80,10 @@ class LoggerConfiguratorPhp implements L
                                                        $layout = 
LoggerReflectionUtils::createObject('LoggerLayoutSimple');
                                                }
                                                
+                                               
if(isset($appenderProperties['file']) && method_exists($appender, 
'setFileName')) { 
+                                                   
$appender->setFile($appenderProperties['file'], true); 
+                                               }
+                                               
                                                if($layout instanceof 
LoggerLayoutPattern) {
                                                        
$layout->setConversionPattern($appenderProperties['layout']['conversionPattern']);
                                                }

Modified: 
logging/log4php/trunk/src/test/php/configurators/LoggerConfiguratorPhpTest.php
URL: 
http://svn.apache.org/viewvc/logging/log4php/trunk/src/test/php/configurators/LoggerConfiguratorPhpTest.php?rev=1071041&r1=1071040&r2=1071041&view=diff
==============================================================================
--- 
logging/log4php/trunk/src/test/php/configurators/LoggerConfiguratorPhpTest.php 
(original)
+++ 
logging/log4php/trunk/src/test/php/configurators/LoggerConfiguratorPhpTest.php 
Tue Feb 15 20:38:43 2011
@@ -54,7 +54,7 @@ class LoggerConfiguratorPhpTest extends 
             'rootLogger' => array (
                 'level' => 'WARN',
                 'appenders' => array (
-                    'default'
+                    'default', 'filetest'
                 ),
             ),
             'loggers' => array (
@@ -78,6 +78,13 @@ class LoggerConfiguratorPhpTest extends 
                         'class' => 'LoggerLayoutSimple'
                     ),
                 ),
+                'filetest' => array (
+                    'class' => 'LoggerAppenderFile',
+                    'file' => '../../../target/temp/xy.log',
+                    'layout' => array (
+                        'class' => 'LoggerLayoutSimple'
+                    ),
+                ),
             ),
             
         ), 'LoggerConfiguratorPhp');
@@ -87,6 +94,14 @@ class LoggerConfiguratorPhpTest extends 
         self :: assertTrue($appender instanceof LoggerAppenderEcho);
         $layout = $appender->getLayout();
         self :: assertTrue($layout instanceof LoggerLayoutSimple);
+        
+        $appender = $root->getAppender("filetest");
+        self :: assertTrue($appender instanceof LoggerAppenderFile);
+        $layout = $appender->getLayout();
+        self :: assertTrue($layout instanceof LoggerLayoutSimple);
+        $file = $appender->getFile();
+        self :: assertEquals('../../../target/temp/xy.log', $file);
+        
         $logger = Logger :: getLogger('mylogger');
         self :: assertEquals(LoggerLevel :: getLevelInfo(), 
$logger->getLevel());
         $logger = Logger :: getLogger('tracer');


Reply via email to