August 2019
Beginner to intermediate
798 pages
17h 2m
English
Sometimes, you just need to write your logging data in a file of your choice. This can happen for many reasons, including writing debugging data, which sometimes can be too much, without messing with the system log files, keeping your own logging data separate from system logs in order to transfer it or store it in a database, and storing your data using a different format. This subsection will teach you how to write to a custom log file.
The name of the Go utility will be customLog.go, and the log file used will be /tmp/mGo.log.
The Go code of customLog.go will be presented in three parts. The first part is as follows:
package main
import (
"fmt"
"log"
"os"
)
var LOGFILE = "/tmp/mGo.log"
The path of the log ...
Read now
Unlock full access