Seldaek/monolog · error · InvalidArgumentException
A stream must either be a resource or a string.
Error message
A stream must either be a resource or a string.
What it means
Error "A stream must either be a resource or a string." thrown in Seldaek/monolog.
Source
Thrown at src/Monolog/Handler/StreamHandler.php:75
// use max 10% of allowed memory for the chunk size, and at least 100KB
$this->streamChunkSize = min(static::MAX_CHUNK_SIZE, max((int) ($phpMemoryLimit / 10), 100 * 1024));
} else {
// memory is unlimited, set to the default 10MB
$this->streamChunkSize = static::DEFAULT_CHUNK_SIZE;
}
} else {
// no memory limit information, set to the default 10MB
$this->streamChunkSize = static::DEFAULT_CHUNK_SIZE;
}
if (\is_resource($stream)) {
$this->stream = $stream;
stream_set_chunk_size($this->stream, $this->streamChunkSize);
} elseif (\is_string($stream)) {
$this->url = Utils::canonicalizePath($stream);
} else {
throw new \InvalidArgumentException('A stream must either be a resource or a string.');
}
$this->fileOpenMode = $fileOpenMode;
$this->filePermission = $filePermission;
$this->useLocking = $useLocking;
}
/**
* @inheritDoc
*/
public function reset(): void
{
parent::reset();
// auto-close on reset to make sure we periodically close the file in long running processes
// as long as they correctly call reset() between jobs
if ($this->url !== null && $this->url !== 'php://memory') {
$this->close();View on GitHub (pinned to 57eb102834)
When it happens
Trigger: Thrown at src/Monolog/Handler/StreamHandler.php:75 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/f8ad4789c0ad4c5f.
Report an issue: GitHub.