For use with the standard "log" and "slog" libraries.
This package generates a log file link that is useful for command-line programs; less so for long-running services.
import flog "github.com/pjsoftware/go-file-logger"
logFile := flog.LogWriter(appName)
defer logFile.Close()
To use this with log
:
flog.UseLog(logFile)
To use this with slog
:
logger := flog.UseSLogJSON(logFile, opts)
or
logger := flog.UseSLogText(logFile, opts)
The file will be created as:
c:\LogFiles\YYYY\MM\DD\YYYYMMDD-appName.log