Open GeorgeXiaojie opened 4 years ago
I also want to know it
change the function of class Logger: public function setLogFilePath($logDirectory) { if ($this->options['filename']) { if (strpos($this->options['filename'], '.log') !== false || strpos($this->options['filename'], '.txt') !== false) { $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename']; } else { $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'].'.'.$this->options['extension']; } } else { $this->logFilePath = $logDirectory . DIRECTORY_SEPARATOR . $this->options['prefix'] . date('Y-m-d') . '.' . $this->options['extension']; } }
to: public function setLogFilePath($logDirectory) { if ($this->options['filename']) { if (strpos($this->options['filename'], '.log') !== false || strpos($this->options['filename'], '.txt') !== false) { $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename']; } else { $this->logFilePath = $logDirectory.DIRECTORY_SEPARATOR.$this->options['filename'].'.'.$this->options['extension']; } } else { $this->logFilePath = $logDirectory . DIRECTORY_SEPARATOR . $this->options['prefix'] . date('Y-m-d') . '.' . $this->options['extension']; $i = 1; while (file_exists($this->logFilePath) && filesize($this->logFilePath) > 5 1024 1024) { $this->logFilePath = $logDirectory . DIRECTORY_SEPARATOR . $this->options['prefix'] . date('Y-m-d') . '(' . $i . ')' . '.' . $this->options['extension']; $i++; } } }
$logger = new Katzgrau\KLogger\Logger(DIR . '/runtime/' . date('Y-m'));
I have a domain process, it write all log to the same file until i restart my process.