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
Advertisement
Something interesting
Tutorials
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+17.9k Golang : Login and logout a user after password verification and redirect example
+6.6k Golang : Totalize or add-up an array or slice example
+19.9k Golang : Count JSON objects and convert to slice/array
+16.4k Golang : How to implement two-factor authentication?
+17.9k Golang : How to make a file read only and set it to writable again?
+9.9k Golang : Function wrapper that takes arguments and return result example
+23.1k Golang : simulate tail -f or read last line from log file example
+11.7k Golang : Find age or leap age from date of birth example
+10.2k Golang : Check a web page existence with HEAD request example
+6.7k Golang : Humanize and Titleize functions