Seldaek/monolog · error · RuntimeException
Failed to open file for reading and writing: {path}
Error message
Failed to open file for reading and writing: {path} What it means
Error "Failed to open file for reading and writing: {path}" thrown in Seldaek/monolog.
Source
Thrown at src/Monolog/Handler/DeduplicationHandler.php:155
/**
* @return string The given record serialized as a single line of text
*/
protected function buildDeduplicationStoreEntry(LogRecord $record): string
{
return $record->datetime->getTimestamp() . ':' . $record->level->getName() . ':' . preg_replace('{[\r\n].*}', '', $record->message);
}
private function collectLogs(): void
{
if (!file_exists($this->deduplicationStore)) {
return;
}
$handle = fopen($this->deduplicationStore, 'rw+');
if (false === $handle) {
throw new \RuntimeException('Failed to open file for reading and writing: ' . $this->deduplicationStore);
}
if (false === flock($handle, LOCK_EX)) {
fclose($handle);
return;
}
$validLogs = [];
$timestampValidity = time() - $this->time;
while (!feof($handle)) {
$log = fgets($handle);
if (\is_string($log) && '' !== $log && substr($log, 0, 10) >= $timestampValidity) {
$validLogs[] = $log;
}
}
ftruncate($handle, 0);View on GitHub (pinned to 57eb102834)
When it happens
Trigger: Thrown at src/Monolog/Handler/DeduplicationHandler.php:155 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/20e09eac6a93c624.
Report an issue: GitHub.