I see logs are printing in console and log file as well, is it possible to disable console logging and write logs only to log file with rlog?
I tried below in main.go file and it redirectsall the logs from main.go to log file only as expected.
newLogFile, err := os.OpenFile("logs/rlog-output.log", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777)
if err == nil {
rlog.Info("About to change log output. Check /logs/rlog-output.log...")
rlog.SetOutput(newLogFile)
rlog.Info("This should go to the new logfile")
}
But, it won't write logs to log file only, If I use rlog functions in another go file.
I see logs are printing in console and log file as well, is it possible to disable console logging and write logs only to log file with rlog?
I tried below in main.go file and it redirectsall the logs from main.go to log file only as expected. newLogFile, err := os.OpenFile("logs/rlog-output.log", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777) if err == nil { rlog.Info("About to change log output. Check /logs/rlog-output.log...") rlog.SetOutput(newLogFile) rlog.Info("This should go to the new logfile") }
But, it won't write logs to log file only, If I use rlog functions in another go file.