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

LoggerAppenderFile creates empty log files

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.0
    • 2.3.0
    • Code
    • None
    • -

    Description

      My configuration uses LoggerAppenderDailyFile with a date pattern which includes seconds, the intent is to create a new log file for each error. The issue I've come across is that at each request it opens the file, then closes it (writing out the footer) without actually logging any error messages. My solution is to move the file-creation code to the time when the first log event is handled.

      My pseudo-patch submission:

      In LoggerAppenderFile.php

      Change
      public function activateOptions()

      { ... }

      to a stub
      public function activateOptions(){ }

      moving the contents of activateOptions to a new function
      protected function open(){
      if($this->fp) return;
      <code from activateOptions here>
      }

      where the new function is called at the start of append()
      public function append(LoggerLoggingEvent $event) {
      if(!$this->fp) $this->open();
      <rest of function>
      }

      Attachments

        Activity

          People

            juice Ivan Habunek
            igornadj igor nadj
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: