Supervisor / supervisor

Supervisor process control system for Unix (supervisord)
http://supervisord.org
Other
8.46k stars 1.24k forks source link

Supervisor sending GOLANG log.Println("Http Sever started at 8080") to error log not the normal log file #1512

Closed khanakia closed 2 years ago

khanakia commented 2 years ago

When i use log.Println("HTTP Server started at 8080") in GOLANG supervisor sends the log to the api.err file not the api.log

Here's my configuration file:

[program:api]
directory=/home/luci
command=/home/luci/appgo server start
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/api.err
stdout_logfile=/var/log/supervisor/api.log
environment=CODENATION_ENV=prod,
    GOPATH=/usr/local/go/bin
jowenn commented 2 years ago

According to: https://pkg.go.dev/log

Package log implements a simple logging package. It defines a type, Logger, with methods for formatting output. It also has a predefined 'standard' Logger accessible through helper functions Print[f|ln], Fatal[f|ln], and Panic[f|ln], which are easier to use than creating a Logger manually. That logger writes to standard error and prints the date and time of each logged message. Every log message is output on a separate line: if the message being printed does not end in a newline, the logger will add one. The Fatal functions call os.Exit(1) after writing the log message. The Panic functions call panic after writing the log message.

The relevant part of the documentation: That logger writes to standard error

In my opinion supervisor behaves correctly in redirecting the output to stderr_logfile

mnaberez commented 2 years ago

The relevant part of the documentation: That logger writes to standard error

It sounds like the function in question is writing to stderr and supervisord is writing it to the stderr_logfile.

This is the intended behavior of supervisord. Anything the child writes to its stderr file descriptor will be written to the stderr_logfile unless redirect_stderr is true.