Log4php
  1. Log4php
  2. LOG4PHP-166

LoggerAppenderMongoDB should supply a timeout value to the Mongo() constructor when it connects for the first time.

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.0, 2.2.0
    • Fix Version/s: 2.2.1
    • Component/s: Code
    • Labels:
      None

      Description

      It would be great if LoggerAppenderMongoDB could supply a timeout value to the Mongo() constructor when it connects for the first time.

      Here's why: If something is wrong with the Mongo database server – for example, if the server is offline – it often takes a really long time (10 or more seconds) to fail and throw an exception. This is terrible in a situation where we need a quick turnaround time and are using the logger to collect diagnostic data.

      Ideally, a timeout value could be specified in the log4php config XML file along with the host, name, etc.

      I already have a patch that fixes this issue. The main gist of it is this. Change this:

      $this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port));

      to this:

      $this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port), array("timeout" => $this->timeout));

      Useful Resources:

        Activity

        Hide
        David Hilowitz added a comment - - edited

        This is the patch I threw together to fix this issue. This patch changes src/main/php/appenders/LoggerAppenderMongoDB.php only.

        Show
        David Hilowitz added a comment - - edited This is the patch I threw together to fix this issue. This patch changes src/main/php/appenders/LoggerAppenderMongoDB.php only.
        Hide
        Ivan Habunek added a comment -

        Thanks for the contribution. I have added the docs & tests for the new parameter. The code is in trunk and will be released in 2.3.

        Show
        Ivan Habunek added a comment - Thanks for the contribution. I have added the docs & tests for the new parameter. The code is in trunk and will be released in 2.3.
        Hide
        Ivan Habunek added a comment -

        That shows why code review is important.
        I have fixed it now. Have another look please.

        Show
        Ivan Habunek added a comment - That shows why code review is important. I have fixed it now. Have another look please.

          People

          • Assignee:
            Ivan Habunek
            Reporter:
            David Hilowitz
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 2h
              2h
              Remaining:
              Remaining Estimate - 2h
              2h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development