I have logging configured using logging.fileConfig()
. I have a the root logger going to a handler that uses SysLogHandler('/dev/log', handlers.SysLogHandler.LOG_USER)
This all works perfectly well, and I see my log entries in /var/log/user.log
The question is how can I set the syslog ident string to something other than python? It appears the syslog module in the standard lib allows setting this when opening a log, but the logging handler doesn't offer this feature.
Would the solution be to subclass SysLogHandler
and use the syslog library inside it's emit method? This is a UNIX only program, so using syslog directly doesn't pose a portability problem.
AFAIK, the ident string is an artifact of the syslog API, see this page. It's just using the C argv[0] which would of course be "python".
I'm surprised that you're getting this using SysLogHandler
with a domain socket, as the message sent to syslog daemons across domain or TCP sockets is just a string with the priority in <angle brackets> followed by the formatted message and a NUL byte. There's no ident string specified by SysLogHandler
, as it doesn't use the syslog API (which has some thread-safety issues in some versions, IIRC).