Uploaded image for project: 'Log4php'
  1. Log4php
  2. LOG4PHP-177

logger writes every message twice

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • 2.2.1
    • None
    • Code
    • None
    • windows 7, php 5.3 (bundled with xampp)

    Description

      The following code and configuration logs everything twice, but is not expected to. This was attempted with both LoggerAppenderConsole and LoggerAppenderFile, maybe reproducible with other appenders as well. If I remove the <appender_ref> tag from the <logger name="MyClass"> element below, the issue no longer occurs, but AFAIU, this kind of workaround should not be required.

      log4php.xml:

      <configuration xmlns="http://logging.apache.org/log4php/">
      <appender name="myAppender" class="LoggerAppenderConsole">
      </appender>
      <root>
      <level value="WARN" />
      <appender_ref ref="myAppender" />
      </root>

      <logger name="MyClass">
      <level value="WARN" />
      <appender_ref ref="myAppender" />
      </logger>
      </configuration>

      index.php:

      Logger::configure('log4php.xml');

      class MyClass {
      protected $logger = null;
      public function __construct()

      { $this->logger = Logger::getLogger(get_class($this)); }

      public function f()

      { $this->logger->warn("f"); }

      }

      $cls = new MyClass();
      $cls->f();

      output:
      WARN - f
      WARN - f

      Attachments

        Activity

          People

            Unassigned Unassigned
            sagimann Sagi Mann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: