Log4php
  1. Log4php
  2. LOG4PHP-126

LoggerConfiguratorPhp does not appear to respect appender file property from config

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.1.0
    • Component/s: Code
    • Labels:
      None
    • Environment:

      all

      Description

      When setting a log file path in an appender block within the php config array, the LoggerConfiguratorPhp::doConfigure does not respect this property.

      I have resolved the issue by adding the following code to the LoggerConfiguratorPhp class after line #80:

      if(isset($appenderProperties['file']) && method_exists($appender, 'setFileName'))

      { $appender->setFile($appenderProperties['file'], true); }

        Activity

        Hide
        Rony Cesana added a comment -

        Hello everyone, I think I have a solution that seems slightly more general.
        In facts I think there were two issues: all of the property definitions were ignored, and the activation method was not called on the appenders.

        After line #86, I added:

        foreach ($appenderProperties as $name => $value) {
        if ($name == 'class' || $name == 'layout')

        { continue; }

        LoggerReflectionUtils::setter($appender, $name, $value);
        }

        $appender->activateOptions();

        Hope this helps.

        Show
        Rony Cesana added a comment - Hello everyone, I think I have a solution that seems slightly more general. In facts I think there were two issues: all of the property definitions were ignored, and the activation method was not called on the appenders. After line #86, I added: foreach ($appenderProperties as $name => $value) { if ($name == 'class' || $name == 'layout') { continue; } LoggerReflectionUtils::setter($appender, $name, $value); } $appender->activateOptions(); Hope this helps.
        Hide
        Christian Grobmeier added a comment -

        Committed with rv1071041 - thanks for the patch!

        Show
        Christian Grobmeier added a comment - Committed with rv1071041 - thanks for the patch!

          People

          • Assignee:
            Unassigned
            Reporter:
            Peter Chapman
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development