August 2019
Beginner to intermediate
798 pages
17h 2m
English
The Go code of logFiles.go will explain the use of the log and log/syslog packages to write to the system log files.
The first part of logFiles.go is as follows:
package main
import (
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
)
func main() {
programName := filepath.Base(os.Args[0])
sysLog, err := syslog.New(syslog.LOG_INFO|syslog.LOG_LOCAL7, programName)
The first parameter to the syslog.New() function is the priority, which is a combination of the logging facility and the logging level. Therefore, a priority of LOG_NOTICE | LOG_MAIL, which is mentioned as an example, will send notice logging ...
Read now
Unlock full access