Log format
The exact shape of a log line: what each segment means, the fixed-width level labels, the JSON alternative, and the default set of masked keys.
Line format (SpringLineFormatter)
The default formatter for format: 'line'. One record per line:
[datetime] [LEVEL] -channel- [pid] (ClassName): message {json}
[datetime] [LEVEL] -channel- [pid]: message {json}| Segment | Source | Notes |
|---|---|---|
[datetime] |
record datetime | Y-m-d H:i:s. |
[LEVEL] |
record level | Fixed 5-char label — see below. |
-channel- |
Monolog channel | The registered channel name (http, cli, sys, …). |
[pid] |
getmypid() |
OS process id of the emitter — always present. Distinguishes forked children in daemons/workers. |
(ClassName) |
context['class'] |
Short class name. Only present when the logger came from getLogger(Class::class); absent for raw channel(). |
message |
log message | As passed. |
{json} |
context + extra |
Merged and JSON-encoded. Omitted when empty. |
The JSON tail merges the call’s context with the injected extra (request context), encoded
with JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES. On a key clash, extra wins.
Examples
[2024-01-01 12:00:00] [INFO ] -http- [4821]: request handled {"request_id":"abc-123"}
[2024-01-01 12:00:00] [DEBUG] -http- [4821] (PpaConnectionPool): FPM connection opened {"class":"App\\Pool\\PpaConnectionPool"}
[2024-01-01 12:00:00] [ERROR] -http- [4821] (UserService): db timeout {"class":"App\\UserService","attempt":3}
[2024-01-01 12:00:00] [WARN ] -sys- [4821]: disk usage highLevel labels
Each level maps to a fixed 5-character label (padded, so columns align):
| Level | Label |
|---|---|
| Debug | DEBUG |
| Info | INFO |
| Notice | NOTIC |
| Warning | WARN |
| Error | ERROR |
| Critical | CRIT |
| Alert | ALERT |
| Emergency | EMERG |
Trailing newline
The formatter appends \n by default. For output: 'syslog' the manager builds it with
appendNewline = false, because syslog frames each message itself. Handled automatically.
JSON format (JsonFormatter)
For format: 'json' — Monolog’s JsonFormatter in newline-delimited batch mode, one JSON
object per line. Suited to log aggregators (Loki, Elasticsearch, Datadog). Empty context and
extra are not omitted, and stack traces are included.
{"message":"user created","context":{"id":42,"class":"App\\Service\\UserService"},"level":200,"level_name":"INFO","channel":"http","datetime":"2024-01-01T12:00:00+00:00","extra":{"request_id":"abc-123"}}Masked keys
The default keys redacted by
SensitiveMaskingProcessor
(case-insensitive, recursive). Each matching value becomes ***:
password passwd secret
token access_token refresh_token
api_key apikey authorization
auth cookie set-cookie
credit_card card_number cvv
ssn pinAdd your own via the constructor — see Mask sensitive data.
Related
- Channel config — choosing
formatandoutput - Log record lifecycle — how a record reaches the formatter
- API reference → Handler & formatter