Skip to content

Commit 1b038e0

Browse files
socketpairvsajip
authored andcommitted
bpo-29808: SysLogHandler: Do not fail if initial connect to syslog failed (#663) (#663)
1 parent 3f2155f commit 1b038e0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Lib/logging/handlers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,14 @@ def __init__(self, address=('localhost', SYSLOG_UDP_PORT),
815815

816816
if isinstance(address, str):
817817
self.unixsocket = True
818-
self._connect_unixsocket(address)
818+
# Syslog server may be unavailable during handler initialisation.
819+
# C's openlog() function also ignores connection errors.
820+
# Moreover, we ignore these errors while logging, so it not worse
821+
# to ignore it also here.
822+
try:
823+
self._connect_unixsocket(address)
824+
except OSError:
825+
pass
819826
else:
820827
self.unixsocket = False
821828
if socktype is None:

0 commit comments

Comments
 (0)