Golang log/syslog.Writer.Err(), Info() and Notice() functions example

package log/syslog

Golang log/syslog.Writer.Err(), Info() and Notice() functions usage example

 package main

 import (
 "log"
 "log/syslog"
 )

 func main() {
 // connection to a log on localhost
 // change localhost to remote server IP address if you want the log message
 // to be sent to the remote server

 logWriter, err := syslog.Dial("udp", "localhost", syslog.LOG_ERR, "Error logger") 
 defer logWriter.Close()
 if err != nil {
 log.Fatal("error")
 }


 logWriter.Err("error")
 logWriter.Notice("notice")
 logWriter.Info("information")
 logWriter.Write([]byte("Hello Logger!"))
 }

References :

http://golang.org/pkg/log/syslog/#Writer.Err

http://golang.org/pkg/log/syslog/#Writer.Info

http://golang.org/pkg/log/syslog/#Writer.Notice

Advertisement