Skip to content
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

When hook is initialised successfully, disable logging to stdout #328

Closed
rogierlommers opened this issue Feb 19, 2016 · 5 comments
Closed

Comments

@rogierlommers
Copy link
Contributor

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?

@aybabtme
Copy link
Collaborator

@rogierlommers you can set the output to be ioutil.Discard. See:

@rogierlommers
Copy link
Contributor Author

Thanks! I have updated my hook readme; included your comment.

@mirdhyn
Copy link

mirdhyn commented Apr 19, 2016

I know it is a closed issue but logrus.SetOutput(ioutil.Discard) doesn't work.
However, log.Out = ioutil.Discard does the job.

@aybabtme
Copy link
Collaborator

@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.

@mirdhyn
Copy link

mirdhyn commented Apr 20, 2016

Thank you for clarifying this @aybabtme :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants