Log4php
  1. Log4php
  2. LOG4PHP-28

LoggerAppenderConsole doesn't write to STDERR

    Details

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

      Description

      How to reproduce:
      1. Take the console example from apache-log4php/trunk/src/examples/php/
      and change the following line in console.properties
      log4php.appender.console.target = STDOUT
      to
      log4php.appender.console.target = STDERR

      2. Run console.php.
      -> Effect: no output to STDERR

      Solution:
      Index: trunk/src/main/php/appenders/LoggerAppenderConsole.php
      ===================================================================
      — trunk/src/main/php/appenders/LoggerAppenderConsole.php (revision 769273)
      +++ trunk/src/main/php/appenders/LoggerAppenderConsole.php (working copy)
      @@ -76,7 +76,7 @@
      if ($v == self::STDOUT || strtoupper($v) == 'STDOUT')

      { $this->target = self::STDOUT; }

      elseif ($v == self::STDERR || strtoupper($v) == 'STDERR')

      { - $target = self::STDERR; + $this->target = self::STDERR; }

      else

      { LoggerLog::debug("Invalid target. Using '".self::STDOUT."' by default."); }

        Activity

        Hide
        Knut Urdalen added a comment -

        Thanks Michael!

        I've added your patch in this changeset:
        http://svn.apache.org/viewvc?view=rev&revision=769355

        However I noticed that at least with PHP 5.2.8 when configuring:
        log4php.appender.console.target = STDERR

        the parse_ini_file() in LoggerPropertyConfigurator is actually converting STDERR to an invalid resource for some reason (var_dump yield "Resource id #3" while is_resource() returns false...).

        The workaround is to enclose the property value with quotation marks like this:
        log4php.appender.console.target = "STDERR"

        which should always work.

        Show
        Knut Urdalen added a comment - Thanks Michael! I've added your patch in this changeset: http://svn.apache.org/viewvc?view=rev&revision=769355 However I noticed that at least with PHP 5.2.8 when configuring: log4php.appender.console.target = STDERR the parse_ini_file() in LoggerPropertyConfigurator is actually converting STDERR to an invalid resource for some reason (var_dump yield "Resource id #3" while is_resource() returns false...). The workaround is to enclose the property value with quotation marks like this: log4php.appender.console.target = "STDERR" which should always work.

          People

          • Assignee:
            Knut Urdalen
            Reporter:
            Michael Kuenzli
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 5m
              5m
              Remaining:
              Remaining Estimate - 5m
              5m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development