Golang log/syslog.Dial() function example
package log/syslog
Golang log/syslog.Dial() function 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.Alert("alert")
logWriter.Crit("critical")
logWriter.Err("error")
logWriter.Warning("warning")
logWriter.Notice("notice")
logWriter.Info("information")
logWriter.Debug("debug")
logWriter.Write([]byte("Hello Logger!"))
}
If you are on Mac OSX. The log messages will appear in the Console application.
Reference :
Advertisement
Something interesting
Tutorials
+8.2k Golang : Qt splash screen with delay example
+8.4k Your page has meta tags in the body instead of the head
+16.3k Golang : How to extract links from web page ?
+21.2k Golang : Get password from console input without echo or masked
+12.1k Golang : Pagination with go-paginator configuration example
+8.2k Golang : Reverse text lines or flip line order example
+15.7k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+14k Golang: Pad right or print ending(suffix) zero or spaces in fmt.Printf example
+7.3k Golang : alternative to os.Exit() function
+10k Golang : Get escape characters \u form from unicode characters
+7.5k Golang : Get YouTube playlist
+18k Golang : Get all upper case or lower case characters from string example