Example 1 — Open, Write, and Close the Logger
Open a log identity, write one message, then close the logger. Return values are shown as a local demo.
<?php
$opened = openlog("demo-app", LOG_PID | LOG_PERROR, LOG_USER);
$written = syslog(LOG_INFO, "Demo message from PHP");
$closed = closelog();
var_dump($opened, $written, $closed); How It Works
- openlog() sets the identity "demo-app" and options.
- syslog() writes an informational message.
- closelog() closes the logger session.
- var_dump() shows that each call returned true in this demo.

