
Wikis & learning
Decide what a log entry needs to explain
A background job can fail when the visitor is no longer present. A structured log record connects the event, the relevant job and the outcome so an operator can follow up.
A background job can fail when the visitor is no longer present. A structured log record connects the event, the relevant job and the outcome so an operator can follow up.
Walkthrough
Choose a small set of fields and encode them consistently. The example uses sample values and prints one serialized record. In deployment, write records to a private log with an appropriate retention period.
PHP example
<?php
$event = ['job' => 17, 'action' => 'render', 'result' => 'complete'];
echo json_encode($event, JSON_THROW_ON_ERROR);Expected output
{"job":17,"action":"render","result":"complete"}Change and check
Add a field for the attempt number. Keep passwords, authorization headers and raw private messages out of the record.
Discussion
Sign in to participate.



