Where does the error log go?

I use log packages and I am wondering what the default destination is for log data. I can not find it anywhere. Do I need an io writer and specifically call him after each magazine or how should it work?

+4
source share
1 answer

It should be stdErrlike line 58log.go :

var std = New(os.Stderr, "", LstdFlags)

Thus, package methods such as Fatal()use std by default:

// Fatal is equivalent to Print() followed by a call to os.Exit(1).
func Fatal(v ...interface{}) {
    std.Output(2, fmt.Sprint(v...))
    os.Exit(1)
}

The blog How to Write Go Packet Encoders Love (by Baron Schwartz) mentions this technique:

, Go, - , -. ( ; , -, .) . .

, , , . , , init().

, , log, - log.Print(). , .
? log.Logger .


, Go 1.13 (Q3 2019) Writer() .

+5

Source: https://habr.com/ru/post/1539834/


All Articles