{"record":{"id":"8cf31047198ec75c","repo":"Seldaek/monolog","slug":"writing-to-the-log-file-failed","errorCode":null,"errorMessage":"Writing to the log file failed: {}","messagePattern":"Writing to the log file failed: (.+?)","errorType":"exception","errorClass":"UnexpectedValueException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Handler/StreamHandler.php","lineNumber":203,"sourceCode":"            return $this->customErrorHandler($code, $msg);\n        });\n        try {\n            $this->streamWrite($stream, $record);\n        } finally {\n            restore_error_handler();\n        }\n        if ($this->errorMessage !== null) {\n            $error = $this->errorMessage;\n            // close the resource if possible to reopen it, and retry the failed write\n            if (!$this->retrying && $this->url !== null && $this->url !== 'php://memory') {\n                $this->retrying = true;\n                $this->close();\n                $this->write($record);\n\n                return;\n            }\n\n            throw new \\UnexpectedValueException('Writing to the log file failed: '.$error . Utils::getRecordMessageForException($record));\n        }\n\n        $this->retrying = false;\n        if ($this->useLocking) {\n            flock($stream, LOCK_UN);\n        }\n    }\n\n    /**\n     * Write to stream\n     * @param resource $stream\n     */\n    protected function streamWrite($stream, LogRecord $record): void\n    {\n        $data = (string) $record->formatted;\n        $length = \\strlen($data);\n        $written = 0;\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/StreamHandler.php#L185-L221","documentation":"Error \"Writing to the log file failed: {}\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/StreamHandler.php:203 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"}