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
+11.3k Golang : How to flush a channel before the end of program?
+4.3k Golang : Converting individual Jawi alphabet to Rumi(Romanized) alphabet example
+13.7k Golang : Check if an integer is negative or positive
+17k Golang : Covert map/slice/array to JSON or XML format
+10.2k Golang : Bcrypting password
+19.4k Golang : How to count the number of repeated characters in a string?
+6.9k Nginx : Password protect a directory/folder
+28.5k Golang : Change a file last modified date and time
+11.2k CodeIgniter : How to check if a session exist in PHP?
+20.9k PHP : Convert(cast) int to double/float
+25.6k Golang : convert rune to integer value
+17.2k Golang : Find file size(disk usage) with filepath.Walk