Seldaek/monolog · error · UnexpectedValueException

The stream or file "%s" could not be opened in append mode:

Error message

The stream or file "%s" could not be opened in append mode: {}

What it means

Error "The stream or file "%s" could not be opened in append mode: {}" thrown in Seldaek/monolog.

Source

Thrown at src/Monolog/Handler/StreamHandler.php:168

            $this->errorMessage = null;
            // forwarding to $this->customErrorHandler using a closure to make the
            // private method accessible, see https://github.com/Seldaek/monolog/issues/1866
            set_error_handler(function (int $code, string $msg) {
                return $this->customErrorHandler($code, $msg);
            });

            try {
                $stream = fopen($url, $this->fileOpenMode);
                if ($this->filePermission !== null) {
                    @chmod($url, $this->filePermission);
                }
            } finally {
                restore_error_handler();
            }
            if (!\is_resource($stream)) {
                $this->stream = null;

                throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in append mode: '.$this->errorMessage, $url) . Utils::getRecordMessageForException($record));
            }
            stream_set_chunk_size($stream, $this->streamChunkSize);
            $this->stream = $stream;
            $this->inodeUrl = $this->getInodeFromUrl();
        }

        $stream = $this->stream;
        if ($this->useLocking) {
            // ignoring errors here, there's not much we can do about them
            flock($stream, LOCK_EX);
        }

        $this->errorMessage = null;
        // forwarding to $this->customErrorHandler using a closure to make the
        // private method accessible, see https://github.com/Seldaek/monolog/issues/1866
        set_error_handler(function (int $code, string $msg) {
            return $this->customErrorHandler($code, $msg);
        });

View on GitHub (pinned to 57eb102834)

When it happens

Trigger: Thrown at src/Monolog/Handler/StreamHandler.php:168 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Seldaek/monolog@57eb102834 (2026-08-17). Data as JSON: /api/errors/acefa04cb5d64126. Report an issue: GitHub.