I have started to use logging module in python. My python code properly logs via several handlers but in my code I still use also syslog module. When I tried to replace it and add just another handler to logging, I found out that output differs.
logging.handlers.SysLogHandler(address = "/dev/log")
...
logging.error("Foo")
syslog.syslog(syslog.LOG_ERR, "Foo")
The output is:
Apr 14 16:42:33 hroch journal: Foo
Apr 2 10:11:51 hroch myscript: Unable to connect/login to fencing device
Attempt to use logging.Formatter did not bring any success as only part after colon is changed.
The address=
parameter to SysLogHandler() should be a (host, port) tuple. Try leaving it off; the default is ('localhost', SYSLOG_UDP_PORT)
, which might be what you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.