You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
logrus_lumberjack "github.com/fallais/logrus-lumberjack-hook"
"github.com/natefinch/lumberjack"
"github.com/rifflock/lfshook"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
)
// Create new instance of logger.
//var log = logrus.New()
func main() {
//log.Out = os.Stdout
pathMap := lfshook.PathMap{
log.InfoLevel: "/home/alan/Documents/dev/GO Tests/File IO/info/info.log",
log.WarnLevel: "/home/alan/Documents/dev/GO Tests/File IO/warn/warn.log",
}
// Set the Lumberjack logger
lumberjackLogger := &lumberjack.Logger{
Filename: "/var/log/misc.log",
MaxSize: 10,
MaxBackups: 3,
MaxAge: 3,
LocalTime: true,
}
// Add Lumberjack hook
hook, err := logrus_lumberjack.NewLumberjackHook(lumberjackLogger)
if err != nil {
logrus.Fatalln("Unable to add the Lumberjack hook :", err)
} else {
logrus.AddHook(hook)
}
myLog := log.New()
myLog.Hooks.Add(lfshook.NewHook(
pathMap,
&log.TextFormatter{},
))
//requestLogger := log.WithFields(log.Fields{"nome": "Name", "sobrenome": "LastName"})
myLog.WithField("Nome", "Alan").Info("This is an INFO log level.")
myLog.WithField("Nome", "Alan").Warn("Hello WOrld")
}
The error:
# command-line-arguments
./main.go:31:50: cannot use lumberjackLogger (type *"github.com/natefinch/lumberjack".Logger) as type *"gopkg.in/natefinch/lumberjack.v2".Logger in argument to logrus_lumberjack.NewLumberjackHoo
The text was updated successfully, but these errors were encountered:
Hi! I just started with g
Go
and I believe your solution May solve my problem.BUt I'm unable to run the example code you gave.
Code:
The error:
The text was updated successfully, but these errors were encountered: