Send syslog messages from Rust
Clone or download
Latest commit ec52990 Aug 27, 2018

Sending to Syslog in Rust

Build Status Coverage Status

A small library to write to local syslog.


syslog is available on and can be included in your Cargo enabled project like this:

syslog = "^4.0"


Reference documentation is available here.


extern crate syslog;

use syslog::{Facility, Formatter3164};

fn main() {
  let formatter = Formatter3164 {
    facility: Facility::LOG_USER,
    hostname: None,
    process: "myprogram".into(),
    pid: 42,

  match syslog::unix(formatter) {
    Err(e)         => println!("impossible to connect to syslog: {:?}", e),
    Ok(mut writer) => {
      writer.err("hello world").expect("could not write error message");

The struct syslog::Logger implements Log from the log crate, so it can be used as backend for other logging systems.

There are 3 functions to create loggers:

  • the unix function sends to the local syslog through a Unix socket: syslog::unix(formatter)
  • the tcp function takes an address for a remote TCP syslog server: tcp(formatter, "")
  • the udp function takes an address for a local port, and the address remote UDP syslog server: udp(formatter, "", "")