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
log
package. Logs will be saved inlogs.txt
.
go run log.go
- Run the following commands to test with built-in
logr
package.
go get github.com/sirupsen/logrus
go run log.go
- Time-stamps in logs - when using either
log
orsirupsen/logrus
- can be modified by setting theTZ
environment variable in the shell. - Built in
log
package is the simplest for generating file name and number. - For JSON formatting of logs, use
sirupsen/logrus
.