Search code examples
pythontransactionspyramidpylons

Disabling logging in 'transaction' package (Pyramid app)


When debugging level of main logger in Pyramid app is set to DEBUG, transaction is spewing lots of pointless debug messages.

In Nosetests I can disable that this way:

from transaction._compat import get_thread_ident

txn_logger = logging.getLogger("txn.%d" % get_thread_ident())
txn_logger.setLevel(logging.WARN)

However, in Pyramid app the infrastructure adds "scoped session" to each HTTP request and that obviously means get_thread_ident() is different every time.

Is there some way of disabling that globally without repeating above in every single Pyramid view?


Solution

  • Simply turn off logging for the txn parent logger in your logging config.

    [loggers]
    keys = transactions, ...
    
    [logger_transactions]
    level = WARN
    handlers =
    qualname = txn