I am trying to remove StreamHandler while my python code is executing.
if (False == consoleOutput):
lhStdout = log.handlers[0] # stdout is the only handler initially
log.removeHandler(lhStdout)
It works great. But I do not like that we assume that stdout is the first handler in an array of handlers. Is there a way to query the handler class to find what type it is? Something like that
for handler in log.handlers
if (handler.type == StreamHandler())
<...>
source
share