Skip to content

Instantly share code, notes, and snippets.

@hnakamur
Created January 7, 2016 17:20
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 hnakamur/75385e5572262b5ce9f6 to your computer and use it in GitHub Desktop.
Save hnakamur/75385e5572262b5ce9f6 to your computer and use it in GitHub Desktop.
go-syslog example
package main
import (
"fmt"
"gopkg.in/mcuadros/go-syslog.v2"
)
func main() {
channel := make(syslog.LogPartsChannel)
handler := syslog.NewChannelHandler(channel)
server := syslog.NewServer()
server.SetFormat(syslog.RFC5424)
server.SetHandler(handler)
server.ListenUDP("0.0.0.0:10514")
server.ListenTCP("0.0.0.0:10514")
server.Boot()
go func(channel syslog.LogPartsChannel) {
for logParts := range channel {
fmt.Println(logParts)
}
}(channel)
server.Wait()
}
@hnakamur
Copy link
Author

hnakamur commented Jan 7, 2016

server

go build -o gosyslogexample gosyslogexample.go
./gosyslogexample

client

$ nc localhost 10514
<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"] BOMAn application event log entry..

This example message are copied from RFC 5424 - The Syslog Protocol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment