Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@hnakamur 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