Go Web App Log

スポンサーリンク

Log

By default, golang has log package (Package log) for logging purpose

import “log”

Usage is simple.

Problem

Simple application usage is O.K.

But, for web application, following codes terminate application. = Web application goes down

package main

import "fmt"
import "log"

func main() {
	log.Fatal("Terminate")
	fmt.Println("Hello")
}

Above, sample codes, terminate application before printing Hello

And, default log package does not have a lot of levels by default

logrus

logrus is structured logger for Go. This is powerful logging for golang.

logrus page show couple of use case, and can check usage.

golang
スポンサーリンク
Professional Programmer2

コメント