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
+12.3k Golang : List running EC2 instances and descriptions
+15.3k Golang : Get all local users and print out their home directory, description and group id
+8.4k Golang : Generate Datamatrix barcode
+12.9k Python : Convert IPv6 address to decimal and back to IPv6
+9.6k Golang : How to extract video or image files from html source code
+5.2k Responsive Google Adsense
+11.8k Golang : Verify Linux user password again before executing a program example
+10.9k Golang : Removes punctuation or defined delimiter from the user's input
+23.9k Golang : Fix type interface{} has no field or no methods and type assertions example
+19.4k Golang : How to count the number of repeated characters in a string?
+12.8k Golang : http.Get example
+7.7k Golang : How to execute code at certain day, hour and minute?