RSY
RSY

Reputation: 51

Logging in Python project using structlog and it logs third party libraries which needs to be removed

I am using structlog library to log for my Python project. I see some third party library logs which I do not want. How do I remove those logs?

Upvotes: 1

Views: 706

Answers (2)

RSY
RSY

Reputation: 51

I solved this by adding the following in my logging setup:

 logging.config.dictConfig({
    'disable_existing_loggers': True, # this disables the existing loggers from logging anything.
... 
})

Upvotes: 0

Dan D.
Dan D.

Reputation: 74655

Logging has a number of locations where you can filter messages. Via the log level of the specific module as in logging.getLogger(...).setLevel(...) or via a filter attached to a logger or attached to a handler.

Upvotes: 2

Related Questions