Skip to content

LogEvent

An immutable structured log event.

Nothing is flattened early: the message template and property bag are preserved so structured sinks (JSON) can emit named fields, while text sinks call LogEvent::renderMessage() to interpolate.

final readonly class LogEvent

SourceLogging/LogEvent.php
PropertyTypeDescription
$categorystringreadonly.
$exception?Throwablereadonly.
$levelLevelreadonly.
$messageTemplatestringreadonly.
$propertiesarrayreadonly.
$scopearrayreadonly.
$timestampfloatreadonly.

public function __construct(float $timestamp, Level $level, string $category, string $messageTemplate, array<string, mixed> $properties = [], array<string, mixed> $scope = [], Throwable|null $exception = null): mixed

From $context[‘exception’] per PSR-3.

ParameterTypeDescription
$timestampfloatUNIX timestamp with microseconds (microtime(true)).
$levelLevel
$categorystring
$messageTemplatestringRaw template, e.g. “Order {orderId} shipped”.
$propertiesarray``<``string``, ``mixed``>Named properties (PSR-3 $context sans “exception”).
$scopearray``<``string``, ``mixed``>Ambient scope properties merged in at emit time.
$exceptionThrowable`“null`

Returns mixed

MethodDescription
renderMessage(): stringInterpolate {placeholder} tokens in the template using properties then scope.

public function renderMessage(): string

Interpolate {placeholder} tokens in the template using properties then scope.

Non-scalar / non-stringable values are left as-is (placeholder kept). Mirrors PSR-3 interpolation semantics.

Returns string