protected function rotateLogFile()
    {
        if (file_exists($this->logFileUrl . '.lock')) {
            return;
        } else {
            touch($this->logFileUrl . '.lock');
        }

        if ($this->logFilesToKeep === 0) {
            unlink($this->logFileUrl);
        } else {
            for ($logFileCount = $this->logFilesToKeep; $logFileCount > 0; --$logFileCount) {
                $rotatedLogFileUrl =  $this->logFileUrl . '.' . $logFileCount;
                if (file_exists($rotatedLogFileUrl)) {
                    if ($logFileCount == $this->logFilesToKeep) {
                        unlink($rotatedLogFileUrl);
                    } else {
                        rename($rotatedLogFileUrl, $this->logFileUrl . '.' . ($logFileCount + 1));
                    }
                }
            }
            rename($this->logFileUrl, $this->logFileUrl . '.1');
        }

        unlink($this->logFileUrl . '.lock');
    }