Answer the question
In order to leave comments, you need to log in
go. Why are the logs displayed in a file and not in the console?
All the logs that I print through log.Println are displayed in the file of the current session of the program, the pid-xxxx.log file is created.
fmt.Println prints to the console
Everything was ok before, maybe it has something to do with it?
if *FD != 0 {
log.Println("Starting with FD ", *FD)
file1 = os.NewFile(uintptr(*FD), "parent socket")
listener1, err = net.FileListener(file1)
if err != nil {
log.Fatalln("fd listener failed: ", err)
}
} else {
log.Println("Virgin Start")
listener1, err = net.Listen("tcp", s.Addr)
if err != nil {
log.Fatalln("listener failed: ", err)
}
}
err = s.Serve(listener1)
Answer the question
In order to leave comments, you need to log in
fmt.Print* uses stdout (os.Stdout) for output, while log.Print* outputs to stderr (os.Stderr). If you really use the standard log package, then apparently os.Stderr is being replaced by another file somewhere (perhaps one of the third-party libraries does this). You can easily check this: try writing something unique to os.Stderr (after all initializations are over) and see where it comes out.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question