Changing logging level at runtime
See original GitHub issueIs there any way to change the output logging level at runtime? I can’t figure out how to do this, but it would be a great feature to add if missing.
Essentially what I want is to be able to define my default logging when the program (a server, in my case) starts up. Then while the program is still running, have the ability to turn the output level up or down. For example, if someone reports a defect, turn the logging to debug
for a while to see what’s going on and try to capture the problem. Then turn it back to warn
or info
for “normal” logging.
I saw that Issue #78 is similar to what I want; though I don’t need a watchdog component.
I tried using the clear()
method followed by add()
with a slightly modified set of options, but if the log level changes rapidly then the file transport can write logs in the wrong order. Not a huge deal, but it would be nice if the level were more easily changed instead of completely removing and re-adding everything.
Issue Analytics
- State:
- Created 10 years ago
- Comments:11 (1 by maintainers)
Top GitHub Comments
In case people run into this in the present, this is now
logger.transports[transportName].level = newLogLevel
DocThis is possible through
logger.setLevels
, if you run into an issue again let us know.