Comments (6)
Quite true. The default formatters set this. The hook then switches on the level
. Did you write your own?
from logrus.
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")
from logrus.
Did you try debugging it from the hook? That seems strange.
from logrus.
❦ 23 novembre 2014 07:14 -0800, Simon Eskildsen [email protected] :
Why are you setting the level twice?
That's a partial code. I am checking if user asked for more debug and
then check to debug. It was just to show you that I may doing
"inappropriate" stuff like start logging stuff before setting the syslog
hook.
/* Thanks to Rob `CmdrTaco' Malda for not influencing this code in any
- way.
*/
2.4.3 linux/net/core/netfilter.c
from logrus.
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:
Nov 23 17:53:23 neo ./test1[31584]: #033[34mDEBU#033[0m[0000] main: this should go to syslog
I wouldn't expect the formatter to be attached only to a given output.
from logrus.
Fixed by #84
from logrus.
Related Issues (20)
- can't build for wasm (go 1.21 rc) HOT 3
- Data race in hooks.test package HOT 3
- virter vm cp not working HOT 2
- Info requested: How to buffer messages and release at the end HOT 2
- Vulnerability of dependency "gopkg.in/yaml.v3" HOT 2
- Logrus potential DOS - Please open a CVE for issue #1370 to encourage users to patch HOT 3
- Feature: Add slog compatibility layer HOT 5
- logrus+lumberjackrus, After the old log is deleted, the hard drive will not be released, HOT 2
- Vulnerability: gopkg.in/yaml.v3 CVE-2022-28948 HOT 2
- Bazel compilation failling HOT 2
- Question: Any way to view the value of a field from a logrus.FieldLogger? HOT 2
- How to apply colours for a custom log format? HOT 2
- How to safely change Logger.Out on the fly? HOT 2
- How should I position my problem? HOT 2
- Cut a new release with wasip1 support? HOT 4
- github.com/interactive-solutions/go-logrus-elasticsearch cannot find HOT 2
- Bump version of stretchr/testify? HOT 3
- Unclear on documentation regarding Hook interface HOT 3
- Please maintain the CHANGELOG HOT 3
- logger.Out.Write's mutex may be unnecessary, when Out is a file fd HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logrus.