:logger handler that sends log lines to a syslog daemon: to a local
socket such as /dev/log (journald, rsyslog, syslog-ng), or over UDP
to a remote host.
Messages use the classic BSD format (RFC 3164) by default:
<22>Oct 4 12:00:00 sovite[812]: queue_id=4Xb2Kq event=queue.message.enqueued queue.message.enqueued: ...with the host name added for remote daemons, or RFC 5424:
<22>1 2026-10-04T12:00:00.123456Z mx1 sovite 812 - - queue_id=4Xb2Kq ...The tag is sovite, the facility mail unless configured, and the
severity follows the log level. The message is the line of the text
formatter without its date and level, or a JSON object with
format: :json. Messages over 8 KiB are cut.
Sending never blocks: when the daemon is not running or cannot keep up, lines are dropped.
Run it under a supervisor, like Sovite.Core.Logging.FileHandler:
{Sovite.Core.Logging.SyslogHandler,
id: :sovite_syslog,
address: {:unix, "/dev/log"},
facility: :mail,
format: :rfc3164,
formatter: Sovite.Core.Logging.formatter(:text)}Options
:id- the:loggerhandler ID. Required.:address-{:unix, path}or{:udp, host, port}. Required.:formatter- the{module, config}formatter of the message. Required.:facility-:mail,:daemon,:user, or:local0to:local7. Defaults to:mail.:format-:rfc3164or:rfc5424. Defaults to:rfc3164.:hostname- for remote daemons and RFC 5424. Defaults to the system's host name.:replace- ID of a handler that is silenced (level:none) while this one runs.
Summary
Functions
@spec encode(:logger.level(), DateTime.t(), iodata(), map()) :: binary()
Encodes one syslog message. time is a UTC DateTime; config has
the :facility, :format, :hostname, :local (no host name in RFC
3164 messages to a local socket), :pid, and :utc (RFC 3164 times
in UTC instead of local time) keys.
@spec start_link(keyword()) :: GenServer.on_start()
Opens the socket and installs the :logger handler.