{"record":{"id":"8ef947eb3a73e170","repo":"Seldaek/monolog","slug":"the-sockets-extension-is-required-to-use-the-syslo","errorCode":null,"errorMessage":"The sockets extension is required to use the SyslogUdpHandler","messagePattern":"The sockets extension is required to use the SyslogUdpHandler","errorType":"exception","errorClass":"MissingExtensionException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Handler/SyslogUdpHandler.php","lineNumber":58,"sourceCode":"    protected string $ident;\n    /** @var self::RFC* */\n    protected int $rfc;\n\n    /**\n     * @param  string                    $host     Either IP/hostname or a path to a unix socket (port must be 0 then)\n     * @param  int                       $port     Port number, or 0 if $host is a unix socket\n     * @param  string|int                $facility Either one of the names of the keys in $this->facilities, or a LOG_* facility constant\n     * @param  bool                      $bubble   Whether the messages that are handled can bubble up the stack or not\n     * @param  string                    $ident    Program name or tag for each log message.\n     * @param  int                       $rfc      RFC to format the message for.\n     * @throws MissingExtensionException when there is no socket extension\n     *\n     * @phpstan-param self::RFC* $rfc\n     */\n    public function __construct(string $host, int $port = 514, string|int $facility = LOG_USER, int|string|Level $level = Level::Debug, bool $bubble = true, string $ident = 'php', int $rfc = self::RFC5424)\n    {\n        if (!\\extension_loaded('sockets')) {\n            throw new MissingExtensionException('The sockets extension is required to use the SyslogUdpHandler');\n        }\n\n        parent::__construct($facility, $level, $bubble);\n\n        $this->ident = $ident;\n        $this->rfc = $rfc;\n\n        $this->socket = new UdpSocket($host, $port);\n    }\n\n    protected function write(LogRecord $record): void\n    {\n        $lines = $this->splitMessageIntoLines($record->formatted);\n\n        $header = $this->makeCommonSyslogHeader($this->toSyslogPriority($record->level), $record->datetime);\n\n        foreach ($lines as $line) {\n            $this->socket->write($line, $header);","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/SyslogUdpHandler.php#L40-L76","documentation":"Error \"The sockets extension is required to use the SyslogUdpHandler\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/SyslogUdpHandler.php:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"57eb1028342134e701e77c617565d51b6e5a2a53","analyzedAt":"2026-08-17T02:36:30.259Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}