Skip to content

Question: Can you set maximum logging level #146

@pelletier197

Description

@pelletier197

Hello,

I am trying to accomplish a logging on different channel depending on the level of the log.

  • If logging level is <= Warning, then log to stdout
  • if logging level is >= Error, then log to stderr

Is there a way to get this work ?

For now I got

	backend := logging.NewLogBackend(os.Stdout, "", 0)
	leveledConsoleBackend = logging.AddModuleLevel(backend)
        // ...
	errorBackend := logging.NewLogBackend(os.Stderr, "", 0)
	leveledConsoleErrorBackend = logging.AddModuleLevel(errorBackend)
	leveledConsoleErrorBackend.SetLevel(logging.ERROR, "")

	logging.SetBackend(leveledConsoleErrorBackend, leveledConsoleBackend)

But with this, I see error logs output both in Stdoud and Stderr

Thank you for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions