-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syslog hook doesn't log anything #82
Comments
Quite true. The default formatters set this. The hook then switches on the |
I didn't set a customer formatter. I am doing that: log.SetOutput(os.Stderr)
log.SetLevel(log.WarnLevel)
log.SetLevel(log.DebugLevel)
log.WithField("file", "something").
Debug("main: parsing configuration file")
syslogOutput, err := logrus_syslog.NewSyslogHook("", "",
syslog.LOG_INFO|syslog.LOG_DAEMON, "")
if err != nil {
log.Fatal("main: unable to setup syslog output")
}
log.AddHook(syslogOutput)
log.WithField("listen", "something").
Info("proxy: start serving requests") |
Did you try debugging it from the hook? That seems strange. |
❦ 23 novembre 2014 07:14 -0800, Simon Eskildsen notifications@github.com :
That's a partial code. I am checking if user asked for more debug and hook./* Thanks to Rob `CmdrTaco' Malda for not influencing this code in any
|
Here is a self contained example: package main
import (
log "github.com/Sirupsen/logrus"
"github.com/Sirupsen/logrus/hooks/syslog"
"log/syslog"
"os"
)
func main() {
/* Setup initial logging */
log.SetOutput(os.Stderr)
log.SetLevel(log.DebugLevel)
syslogOutput, err := logrus_syslog.NewSyslogHook("", "",
syslog.LOG_INFO|syslog.LOG_DAEMON, "")
if err != nil {
log.Fatal("main: unable to setup syslog output")
}
log.AddHook(syslogOutput)
log.Debug("main: this should go to syslog")
} If I leave syslog.go unchanged, nothing gets logged to syslog. It seems that this is the same problem as with #72. I'll do a pull request for that in a few minutes. Once fixed, I still have that in syslog:
I wouldn't expect the formatter to be attached only to a given output. |
Log level has moved from `entry.Data["level"]` to `entry.Level`. Use that to get the right level. Fix: sirupsen#82
Fixed by #84 |
Hi!
The syslog hook doesn't log anything unless a field "level" is set by the user.
It can be corrected by using
entry.Level.String()
insyslog.go
. However, in this case, logging is done with ANSI codes (I get something like this:#033[34mINFO#033[0m[0000] proxy: start serving requests
).The text was updated successfully, but these errors were encountered: