Created
March 31, 2015 23:16
-
-
Save giefferre/ff7f58c342247bab9bcb to your computer and use it in GitHub Desktop.
Using a remote rsyslog in Golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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