Syslog
Jump to navigation
Jump to search
echo "test" | nc -v -u -w 0 127.0.0.1 9514
https://github.com/jeremybusk/go-syslog
go mod init a go get gopkg.in/mcuadros/go-syslog.v2
log.go
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:9514") server.Boot() go func(channel syslog.LogPartsChannel) { for logParts := range channel { fmt.Println(logParts) } }(channel) server.Wait() }
go build log