I am using supervisord to run my golang app. My supervisord conf looks like
[program:go_web]
command=go-web-app
autostart=true
autorestart=true
startsecs=3
stdout_logfile=/var/log/app.log
stderr_logfile=/var/log/app_error.log
and my logrus setup looks:
package main
import (
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
)
func main() {
log.SetFormatter(&logrus.TextFormatter{
ForceColors: true,
})
log.Info("this is an info")
log.Error("this is an error")
}
However I found both log in my error log /var/log/app_error.log
INFO[0000] this is an info
ERRO[0000] this is an error
How can I make info logging to my app log /var/log/app.log and error logging to error log var/log/app_error.log automatically.
Thanks
structthat implements theWriterinterface, and put your conditioned logic there, i.e where the logs should be written to based on log level.And then use that struct to write logs by logrus.
/var/log/app_error.logand others will go to/var/log/app.log