Skip to content

Level

Ordinal log level with minimum-level (>=) semantics.

Aligned to PSR-3 / RFC 5424 so a PSR-3 level string maps directly, with an extra Level::Trace below Debug (Serilog “Verbose”) that degrades to “debug” on PSR-3 output. Higher value = more severe. A message passes a threshold when $message->value >= $threshold->value.

enum Level: int

SourceLogging/Level.php
CaseValueDescription
Trace50
Debug100
Info200
Notice250
Warning300
Error400
Critical500
Alert550
Emergency600
PropertyTypeDescription
$namestringreadonly.
$valueintreadonly.
MethodDescription
cases(): array
[`from(stringint $value): static`](#from)
fromName(string $name): LevelParse a case-insensitive level name for configuration (e.g.
fromPsr(string $psrLevel): LevelMap a PSR-3 LogLevel string to a Level.
label(): stringLowercase canonical name used in structured output (e.g.
passes(Level $threshold): boolWhether a message at $this level passes the given minimum threshold.
toPsr(): stringThe PSR-3 level string for this level.
[`tryFrom(stringint $value): ?static`](#tryfrom)

public static function cases(): array

Returns array

public static function from(string|int $value): static

ParameterTypeDescription
$value`string““int`

Returns static

public static function fromName(string $name): Level

Parse a case-insensitive level name for configuration (e.g.

LOG_LEVEL=info). Accepts “warn” as an alias for “warning”.

ParameterTypeDescription
$namestring

Returns Level

ThrowsWhen
InvalidArgumentExceptionon an unknown name.

public static function fromPsr(string $psrLevel): Level

Map a PSR-3 LogLevel string to a Level.

ParameterTypeDescription
$psrLevelstring

Returns Level

ThrowsWhen
InvalidArgumentExceptionon an unknown level (PSR-3 requirement).

public function label(): string

Lowercase canonical name used in structured output (e.g.

“trace”, “warning”).

Returns string

public function passes(Level $threshold): bool

Whether a message at $this level passes the given minimum threshold.

ParameterTypeDescription
$thresholdLevel

Returns bool

public function toPsr(): string

The PSR-3 level string for this level.

Trace has no PSR-3 equivalent and degrades to “debug”.

Returns string

public static function tryFrom(string|int $value): ?static

ParameterTypeDescription
$value`string““int`

Returns ?``static