{"record":{"id":"45482ebaa8da7347","repo":"Seldaek/monolog","slug":"missing-stream-url-the-stream-can-not-be-opened","errorCode":null,"errorMessage":"Missing stream url, the stream can not be opened. This may be caused by a premature call to close().","messagePattern":"Missing stream url, the stream can not be opened\\. This may be caused by a premature call to close\\(\\)\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Handler/StreamHandler.php","lineNumber":147,"sourceCode":"        return $this->streamChunkSize;\n    }\n\n    /**\n     * @inheritDoc\n     */\n    protected function write(LogRecord $record): void\n    {\n        if ($this->hasUrlInodeWasChanged()) {\n            $this->close();\n            $this->write($record);\n\n            return;\n        }\n\n        if (!\\is_resource($this->stream)) {\n            $url = $this->url;\n            if (null === $url || '' === $url) {\n                throw new \\LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().' . Utils::getRecordMessageForException($record));\n            }\n            $this->createDir($url);\n            $this->errorMessage = null;\n            // forwarding to $this->customErrorHandler using a closure to make the\n            // private method accessible, see https://github.com/Seldaek/monolog/issues/1866\n            set_error_handler(function (int $code, string $msg) {\n                return $this->customErrorHandler($code, $msg);\n            });\n\n            try {\n                $stream = fopen($url, $this->fileOpenMode);\n                if ($this->filePermission !== null) {\n                    @chmod($url, $this->filePermission);\n                }\n            } finally {\n                restore_error_handler();\n            }\n            if (!\\is_resource($stream)) {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/StreamHandler.php#L129-L165","documentation":"Error \"Missing stream url, the stream can not be opened. This may be caused by a premature call to close().\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/StreamHandler.php:147 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"57eb1028342134e701e77c617565d51b6e5a2a53","analyzedAt":"2026-08-17T02:36:30.259Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}