private function doConfigure($url, Ideasa_Log4php_LoggerHierarchy $hierarchy)
 {
     if (!is_array($url)) {
         $config = (require $url);
     } else {
         $config = $url;
     }
     // set threshold
     if (isset($config['threshold'])) {
         $hierarchy->setThreshold(Ideasa_Log4php_Helpers_LoggerOptionConverter::toLevel($config['threshold'], Ideasa_Log4php_LoggerLevel::getLevelAll()));
     }
     // add renderes
     if (isset($config['renderers'])) {
         foreach ($config['renderers'] as $renderedClass => $renderingClass) {
             $hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClass);
         }
     }
     // parse and create appenders
     if (isset($config['appenders'])) {
         foreach ($config['appenders'] as $appenderName => $appenderProperties) {
             $appender = Ideasa_Log4php_LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']);
             // unset so that the property wont be drawn up again
             unset($appenderProperties['class']);
             if ($appender->requiresLayout()) {
                 if (isset($appenderProperties['layout'])) {
                     if (isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) {
                         $layoutClass = $appenderProperties['layout']['class'];
                     } else {
                         $layoutClass = 'Ideasa_Log4php_Layouts_LoggerLayoutSimple';
                     }
                     $layout = Ideasa_Log4php_LoggerReflectionUtils::createObject($layoutClass);
                     if ($layout === null) {
                         $layout = Ideasa_Log4php_LoggerReflectionUtils::createObject('Ideasa_Log4php_Layouts_LoggerLayoutSimple');
                     }
                     if (isset($appenderProperties['file']) && method_exists($appender, 'setFileName')) {
                         $appender->setFile($appenderProperties['file'], true);
                     }
                     if ($layout instanceof Ideasa_Log4php_Layouts_LoggerLayoutPattern) {
                         $layout->setConversionPattern($appenderProperties['layout']['conversionPattern']);
                     }
                     $appender->setLayout($layout);
                     // unset so that the property wont be drawn up again
                     unset($appenderProperties['layout']);
                 } else {
                     // TODO: throw exception?
                 }
             }
             // set remaining properties and activate appender
             $setter = new Ideasa_Log4php_LoggerReflectionUtils($appender);
             foreach ($appenderProperties as $key => $val) {
                 $setter->setProperty($key, $val);
             }
             $setter->activate();
         }
     }
     // parse and create root logger
     if (isset($config['rootLogger'])) {
         $rootLogger = $hierarchy->getRootLogger();
         if (isset($config['rootLogger']['level'])) {
             $rootLogger->setLevel(Ideasa_Log4php_Helpers_LoggerOptionConverter::toLevel($config['rootLogger']['level'], Ideasa_Log4php_LoggerLevel::getLevelDebug()));
             if (isset($config['rootLogger']['appenders'])) {
                 foreach ($config['rootLogger']['appenders'] as $appenderName) {
                     $appender = Ideasa_Log4php_LoggerAppenderPool::getAppenderFromPool($appenderName);
                     if ($appender !== null) {
                         $rootLogger->addAppender($appender);
                     }
                 }
             }
         }
     }
     // parse and create loggers
     if (isset($config['loggers'])) {
         foreach ($config['loggers'] as $loggerName => $loggerProperties) {
             if (is_string($loggerName)) {
                 $logger = $hierarchy->getLogger($loggerName);
                 if (isset($loggerProperties['level'])) {
                     $logger->setLevel(Ideasa_Log4php_Helpers_LoggerOptionConverter::toLevel($loggerProperties['level'], Ideasa_Log4php_LoggerLevel::getLevelDebug()));
                     if (isset($loggerProperties['appenders'])) {
                         foreach ($loggerProperties['appenders'] as $appenderName) {
                             $appender = Ideasa_Log4php_LoggerAppenderPool::getAppenderFromPool($appenderName);
                             if ($appender !== null) {
                                 $logger->addAppender($appender);
                             }
                         }
                     }
                 }
             } else {
                 // TODO: throw exception
             }
         }
     }
     return true;
 }
 /**
  * Parse non-root elements, such non-root categories and renderers.
  *
  * @param array $props array of properties
  * @param Ideasa_Log4php_LoggerHierarchy $hierarchy
  */
 private function parseCatsAndRenderers($props, Ideasa_Log4php_LoggerHierarchy $hierarchy)
 {
     while (list($key, $value) = each($props)) {
         if (strpos($key, self::CATEGORY_PREFIX) === 0 or strpos($key, self::LOGGER_PREFIX) === 0) {
             if (strpos($key, self::CATEGORY_PREFIX) === 0) {
                 $loggerName = substr($key, strlen(self::CATEGORY_PREFIX));
             } else {
                 if (strpos($key, self::LOGGER_PREFIX) === 0) {
                     $loggerName = substr($key, strlen(self::LOGGER_PREFIX));
                 }
             }
             $logger = $hierarchy->getLogger($loggerName);
             $this->parseCategory($props, $logger, $key, $loggerName, $value);
             $this->parseAdditivityForLogger($props, $logger, $loggerName);
         } else {
             if (strpos($key, self::RENDERER_PREFIX) === 0) {
                 $renderedClass = substr($key, strlen(self::RENDERER_PREFIX));
                 $renderingClass = $value;
                 $hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClass);
             }
         }
     }
 }
 /**
  * @param mixed $parser
  * @param string $tag
  * @param array $attribs
  *
  * @todo In 'LOGGER' case find a better way to detect 'getLogger()' method
  */
 private function tagOpen($parser, $tag, $attribs)
 {
     switch ($tag) {
         case 'CONFIGURATION':
         case self::XMLNS . ':CONFIGURATION':
             if (isset($attribs['THRESHOLD'])) {
                 $this->repository->setThreshold(Ideasa_Log4php_Helpers_LoggerOptionConverter::toLevel($this->subst($attribs['THRESHOLD']), $this->repository->getThreshold()));
             }
             break;
         case 'APPENDER':
         case self::XMLNS . ':APPENDER':
             unset($this->appender);
             $this->appender = null;
             $name = $this->subst(@$attribs['NAME']);
             $class = $this->subst(@$attribs['CLASS']);
             $this->appender = Ideasa_Log4php_LoggerAppenderPool::getAppenderFromPool($name, $class);
             if (isset($attribs['THRESHOLD'])) {
                 $this->appender->setThreshold(Ideasa_Log4php_Helpers_LoggerOptionConverter::toLevel($this->subst($attribs['THRESHOLD']), $this->appender->getThreshold()));
             }
             $this->state[] = self::APPENDER_STATE;
             break;
         case 'APPENDER_REF':
         case 'APPENDER-REF':
         case self::XMLNS . ':APPENDER_REF':
         case self::XMLNS . ':APPENDER-REF':
             if (isset($attribs['REF']) and !empty($attribs['REF'])) {
                 $appenderName = $this->subst($attribs['REF']);
                 $appender = Ideasa_Log4php_LoggerAppenderPool::getAppenderFromPool($appenderName);
                 if ($appender !== null) {
                     switch (end($this->state)) {
                         case self::LOGGER_STATE:
                         case self::ROOT_STATE:
                             $this->logger->addAppender($appender);
                             break;
                     }
                 }
             }
             break;
         case 'FILTER':
         case self::XMLNS . ':FILTER':
             unset($this->filter);
             $this->filter = null;
             $filterName = basename($this->subst(@$attribs['CLASS']));
             if (!empty($filterName)) {
                 $this->filter = new $filterName();
                 $this->state[] = self::FILTER_STATE;
             }
             break;
         case 'LAYOUT':
         case self::XMLNS . ':LAYOUT':
             $class = @$attribs['CLASS'];
             $this->layout = Ideasa_Log4php_LoggerReflectionUtils::createObject($this->subst($class));
             $this->state[] = self::LAYOUT_STATE;
             break;
         case 'LOGGER':
         case self::XMLNS . ':LOGGER':
             // $this->logger is assigned by reference.
             // Only '$this->logger=null;' destroys referenced object
             unset($this->logger);
             $this->logger = null;
             $loggerName = $this->subst(@$attribs['NAME']);
             if (!empty($loggerName)) {
                 $this->logger = $this->repository->getLogger($loggerName);
                 if ($this->logger !== null and isset($attribs['ADDITIVITY'])) {
                     $additivity = Ideasa_Log4php_Helpers_LoggerOptionConverter::toBoolean($this->subst($attribs['ADDITIVITY']), true);
                     $this->logger->setAdditivity($additivity);
                 }
             }
             $this->state[] = self::LOGGER_STATE;
             break;
         case 'LEVEL':
         case self::XMLNS . ':LEVEL':
         case 'PRIORITY':
         case self::XMLNS . ':PRIORITY':
             if (!isset($attribs['VALUE'])) {
                 // LoggerDOMConfigurator::tagOpen() LEVEL value not set
                 break;
             }
             if ($this->logger === null) {
                 // LoggerDOMConfigurator::tagOpen() LEVEL. parent logger is null
                 break;
             }
             switch (end($this->state)) {
                 case self::ROOT_STATE:
                     $this->logger->setLevel(Ideasa_Log4php_Helpers_LoggerOptionConverter::toLevel($this->subst($attribs['VALUE']), $this->logger->getLevel()));
                     break;
                 case self::LOGGER_STATE:
                     $this->logger->setLevel(Ideasa_Log4php_Helpers_LoggerOptionConverter::toLevel($this->subst($attribs['VALUE']), $this->logger->getLevel()));
                     break;
                 default:
                     //LoggerLog::warn("LoggerDOMConfigurator::tagOpen() LEVEL state '{$this->state}' not allowed here");
             }
             break;
         case 'PARAM':
         case self::XMLNS . ':PARAM':
             if (!isset($attribs['NAME'])) {
                 // LoggerDOMConfigurator::tagOpen() PARAM attribute 'name' not defined.
                 break;
             }
             if (!isset($attribs['VALUE'])) {
                 // LoggerDOMConfigurator::tagOpen() PARAM. attribute 'value' not defined.
                 break;
             }
             switch (end($this->state)) {
                 case self::APPENDER_STATE:
                     if ($this->appender !== null) {
                         Ideasa_Log4php_LoggerReflectionUtils::setter($this->appender, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));
                     }
                     break;
                 case self::LAYOUT_STATE:
                     if ($this->layout !== null) {
                         Ideasa_Log4php_LoggerReflectionUtils::setter($this->layout, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));
                     }
                     break;
                 case self::FILTER_STATE:
                     if ($this->filter !== null) {
                         Ideasa_Log4php_LoggerReflectionUtils::setter($this->filter, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));
                     }
                     break;
                 default:
                     //LoggerLog::warn("LoggerDOMConfigurator::tagOpen() PARAM state '{$this->state}' not allowed here");
             }
             break;
         case 'RENDERER':
         case self::XMLNS . ':RENDERER':
             $renderedClass = $this->subst(@$attribs['RENDEREDCLASS']);
             $renderingClass = $this->subst(@$attribs['RENDERINGCLASS']);
             if (!empty($renderedClass) and !empty($renderingClass)) {
                 $this->repository->getRendererMap()->addRenderer($renderedClass, $renderingClass);
             }
             break;
         case 'ROOT':
         case self::XMLNS . ':ROOT':
             $this->logger = Ideasa_Log4php_Logger::getRootLogger();
             $this->state[] = self::ROOT_STATE;
             break;
     }
 }