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
+5.9k Golang : Generate multiplication table from an integer example
+18.5k Golang : Example for RSA package functions
+11.9k Golang : Convert decimal number(integer) to IPv4 address
+22.1k Golang : Match strings by wildcard patterns with filepath.Match() function
+21.6k Golang : GORM create record or insert new record into database example
+6.2k PHP : Get client IP address
+5.6k PHP : Convert string to timestamp or datestamp before storing to database(MariaDB/MySQL)
+13.6k Golang : reCAPTCHA example
+5.3k PHP : Hide PHP version information from curl
+9.5k Golang : Changing a RGBA image number of channels with OpenCV
+9.9k Golang : ffmpeg with os/exec.Command() returns non-zero status
+16k Golang : Get sub string example