Python: Remover um handler de uma configuração Logging

Republicação de kite
import logging
import logging.handlers
import sys

logger = logging.getLogger()
logger.setLevel(logging.INFO)

stdlog = logging.StreamHandler(sys.stdout)
syslog = logging.handlers.SysLogHandler(address=("localhost", 8000))
logger.addHandler(stdlog)
logger.addHandler(syslog)
print logger.handlers
Output
[<logging.StreamHandler object at 0x7f6526a20250>, <logging.handlers.SysLogHandler object at 0x7f6526a20290>]
logger.handlers.pop()

print logger.handlers
Output
[<logging.StreamHandler object at 0x7f6526a20250>]
logger.info("This is an info message")
Output
This is an info message

Comentários