Issue 21807: SysLogHandler closes TCP connection after first message (original) (raw)
Issue21807
Created on 2014-06-19 08:12 by Omer.Katz, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg220961 - (view) | Author: Omer Katz (Omer.Katz) * | Date: 2014-06-19 08:12 |
import logging import logging.handlers import socket logger = logging.getLogger('mylogger') handler = logging.handlers.SysLogHandler(('****', logging.handlers.SYSLOG_TCP_PORT), socktype=socket.SOCK_STREAM) formatter = logging.Formatter('%(name)s: [%(levelname)s] %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) logger.info("TEST 1") logger.info("TEST 2") I have verified that this code only sends 'TEST 1' to Splunk and syslog-ng on both Python 2.7 and Python 3.4. After that, the connection appears closed. UDP on the other hand works just fine. | ||
msg220993 - (view) | Author: Vinay Sajip (vinay.sajip) * ![]() |
Date: 2014-06-19 15:30 |
Some information appears to be missing from your snippet: the default logger level is WARNING, so no INFO messages would be expected. Have you set logging.raiseExceptions to a False value? Are you sure that no network error is occurring? How can you be sure the other end isn't closing the connection? I ask these questions, because there is no code called to explicitly close the socket, unless an error occurs. Also, no one else has ever reported this problem, and this code hasn't changed in a long time, IIRC. | ||
msg221349 - (view) | Author: Vinay Sajip (vinay.sajip) * ![]() |
Date: 2014-06-23 12:00 |
The default for syslog-ng's so_keepalive() option is No (don't keep the socket open). Since you haven't responded with more information, I'll assume that you're using this default setting, and that syslog-ng is terminating the connection. Reopen if you have information to the contrary. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:05 | admin | set | github: 66006 |
2014-06-23 12:00:50 | vinay.sajip | set | status: open -> closedresolution: not a bugmessages: + |
2014-06-19 15:30:13 | vinay.sajip | set | messages: + |
2014-06-19 13:59:40 | r.david.murray | set | nosy: + vinay.sajip |
2014-06-19 08:12:08 | Omer.Katz | create |