Besides the logging with the default logger from the log package, the standard library also provides a way to create the custom logger, according to the needs of the application or package. This recipe will give a brief insight on how to create one.
Logging customization
How to do it...
- Open the console and create the folder chapter11/recipe01.
- Navigate to the directory.
- Create the file logging.go with the following content:
package main
import (
"log"
"os"
)
func main() {
custLogger := log.New(os.Stdout, "custom1: ",
log.Ldate|log.Ltime)
custLogger.Println("Hello I'm customized")
...