romana / rlog

A simple Golang logger without external dependencies
Apache License 2.0
39 stars 14 forks source link

disable console logging #22

Closed CKFVL closed 6 years ago

CKFVL commented 6 years ago

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.