Browse Source

Write log into separate log-file

Fabian Vowie 3 years ago
parent
commit
2185549e9c
No known key found for this signature in database GPG Key ID: C27317C33B27C410
  1. 1
      .gitignore
  2. 9
      main.go

1
.gitignore

@ -16,3 +16,4 @@ go.work
# Lithium specific # Lithium specific
settings.json settings.json
lithium.log

9
main.go

@ -148,8 +148,15 @@ func RegisterRoutes(r *mux.Router, pipelines []pipelines.IPipeline, storageProvi
} }
func main() { func main() {
logFile, err := os.OpenFile("lithium.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err == nil {
multiWriter := io.MultiWriter(os.Stdout, logFile)
logrus.SetOutput(multiWriter)
} else {
logrus.SetOutput(os.Stdout)
}
logrus.SetFormatter(&logrus.JSONFormatter{}) logrus.SetFormatter(&logrus.JSONFormatter{})
logrus.SetOutput(os.Stdout)
appSettings, err := settings.LoadSettings(afero.NewOsFs()) appSettings, err := settings.LoadSettings(afero.NewOsFs())
if err != nil { if err != nil {

Loading…
Cancel
Save