Difference between revisions of "Syslog"
Jump to navigation
Jump to search
(Created page with "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 (...") |
|||
Line 1: | Line 1: | ||
echo "test" | nc -v -u -w 0 127.0.0.1 9514 | echo "test" | nc -v -u -w 0 127.0.0.1 9514 | ||
+ | |||
+ | logger --udp --port 9514 -n 127.0.0.1 "Test message" | ||
https://github.com/jeremybusk/go-syslog | https://github.com/jeremybusk/go-syslog |
Revision as of 19:57, 21 October 2021
echo "test" | nc -v -u -w 0 127.0.0.1 9514
logger --udp --port 9514 -n 127.0.0.1 "Test message"
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