A basic implementation of logging with Go language. Copied from https://www.honeybadger.io/blog/golang-logging/
- Run the following commands to test with built-in
logpackage. Logs will be saved inlogs.txt.
go run log.go- Run the following commands to test with built-in
logrpackage.
go get github.com/sirupsen/logrus
go run log.go- Time-stamps in logs - when using either
logorsirupsen/logrus- can be modified by setting theTZenvironment variable in the shell. - Built in
logpackage is the simplest for generating file name and number. - For JSON formatting of logs, use
sirupsen/logrus.