Skip to content

Instantly share code, notes, and snippets.

@giefferre
Created March 31, 2015 23:16
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save giefferre/ff7f58c342247bab9bcb to your computer and use it in GitHub Desktop.
Save giefferre/ff7f58c342247bab9bcb to your computer and use it in GitHub Desktop.
Using a remote rsyslog in Golang
package main
import (
"log"
"log/syslog"
)
func main() {
logwriter, e := syslog.Dial("tcp","123.123.123.123:12345", syslog.LOG_DEBUG, "your.software.identifier")
if e != nil {
log.Fatal(e)
}
// normal logs
logwriter.Info("This is a test!")
// you can even send JSON like messages like this:
logwriter.Info(`@cee:{"key1":"value1", "key2":"value2"}`)
// more details about JSON CEE format in rsyslog:
// http://www.rsyslog.com/json-elasticsearch/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment