Where do I find the log and how do I read it

(Calvin Cani) #1

I have an app and part of what the app does is write to the log. Where do I find this log because I cannot find it at all. Is there a command you must run to view the log or what?

(Curtis Allyn Green) #2

Read over this as it will explain in more detail about the logging package.

By default the log is printed to the console you run your application from, but can be set to a specified file.

(Johan Dahl) #3

Interesting article! However one thing which is wrong in the article is “don’t log from go routines”. All functions of package log goes thru a function which uses a mutex so multiple go routines can write to same log.

For example https://golang.org/src/log/log.go?s=6167:6207#L188

func (l *Logger) Println(v ...interface{}) { l.Output(2, fmt.Sprintln(v...)) }

calls l.Output https://golang.org/src/log/log.go?s=6167:6207#L149 which uses a mutex

func (l *Logger) Output(calldepth int, s string) error {
	now := time.Now() // get this early.
	var file string
	var line int
	defer l.mu.Unlock()

(Calvin Cani) #4

Thank you for your inset it’s much appreciated

(Calvin Cani) #5

Thank you I will read over it