Skip to content

Instantly share code, notes, and snippets.

@moronkreacionz
Forked from giefferre/remote-rsyslog.go
Created July 13, 2016 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moronkreacionz/0096f24777ef55e68d4b60380c3a80d2 to your computer and use it in GitHub Desktop.
Save moronkreacionz/0096f24777ef55e68d4b60380c3a80d2 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