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
+6.6k Golang : Warp text string by number of characters or runes example
+12.6k Golang : flag provided but not defined error
+7k Golang : constant 20013 overflows byte error message
+10.9k Golang : How to transmit update file to client by HTTP request example
+6.1k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+6.5k Grep : How to grep for strings inside binary data
+16.5k Golang : Check if a string contains multiple sub-strings in []string?
+24.6k Golang : How to validate URL the right way
+7.3k Golang : alternative to os.Exit() function
+15.3k Golang : Get all local users and print out their home directory, description and group id
+12.1k Golang : Save webcamera frames to video file
+7.2k Golang : Null and nil value