mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 08:05:53 +03:00
[GH-ISSUE #1085] SyslogUdpHandler - Call to socket_sendto() throws a Fatal error: uncaught exception if a wrong / unreachable IP is given. #440
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#440
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mrtariqkhan on GitHub (Nov 22, 2017).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1085
$handler = new SyslogUdpHandler('192.168.225.3668', 514, LOG_USER, env('LOG_LEVEL', 'DEBUG'));
$handler->setFormatter($lineformatter);
$monolog->pushHandler($handler);
results in
2017/11/22 13:41:45 [error] 1612#1612: *177 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught ErrorException: socket_sendto(): Host lookup failed [-10001]: Unknown host in /home/project/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php:47
Stack trace:
-0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'socket_sendto()...', '/home/...', 47, Array)
-1 vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php(47): socket_sendto(Resource id #4, '<11>1 2017-11-2...', 274, 0, '192.168.225.564', 514)
-2 vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php(31): Monolog\Handler\SyslogUdp\UdpSocket->send('<11>1 2017-11-2...')
-3 vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php(51): Monolog\Handler\SyslogUdp\UdpSocket->write('2017-11-22T13:4...', '<11>1 2017-11-2...')
Is there a reason its this way and not caught gracefully?
@tomzx commented on GitHub (Jan 5, 2018):
192.168.225.3668is not a valid ip address.@mrtariqkhan commented on GitHub (Jan 29, 2018):
indeed it is, the problem is it throws out an unhandeled fatal exception. Which is an issue if the supplied IP or domain name goes down for some reason. In my case its the rsyslogd server which went down and took the whole application down with it.
@Seldaek commented on GitHub (Jun 17, 2018):
You should use a WhatFailureGroupHandler if you want to swallow errors in handlers.