Most of the time I'm logging to a Redis host, which pipes messages straight to an ELK stack. I'm wondering if it is possible to disable all output to stdout/err at the time a hook is initialised successfully.
For example:
hook, err := logredis.NewHook("localhost", 6379, "my_redis_key", "my_app_name")
if err == nil {
log.AddHook(hook)
log.DisableStdOut()
}
So once the hook is in use, disable all output to stdout. Is this possible now?
@rogierlommers you can set the output to be ioutil.Discard. See:
Thanks! I have updated my hook readme; included your comment.
I know it is a closed issue but logrus.SetOutput(ioutil.Discard) doesn't work.
However, log.Out = ioutil.Discard does the job.
@mirdhyn SetOutput will work on the global logger, but you're right that a logger created with New will need to have its output changed this way.
Thank you for clarifying this @aybabtme :)
Most helpful comment
@rogierlommers you can set the output to be
ioutil.Discard. See: