R
R
recloudor2016-07-12 09:35:14
go
recloudor, 2016-07-12 09:35:14

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

1 answer(s)
S
Sevlyar, 2016-11-06
@Sevlyar

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 question

Ask a Question

731 491 924 answers to any question