Intercepting logging logs
See original GitHub issueI am using the recommended InterceptHandler
as documented, but I am still getting logs from different loggers around from 3rd party libs.
I am able to get them intercepted by using something like:
_log = logging.getLogger('aioredis')
_log.handlers = [InterceptHandler()]
But then I am getting double log-messages for aioredis
, one default and one with the loguru format.
Setting logging.basicConfig(handlers=[InterceptHandler()], level=0)
isnt doing much either.
Have I missunderstood what this InterceptHandler() is supposed to do? I have the log-config code as early in my code as possible.
Maybe the aioredis lib is changing my config later?
Any tips on a proper way to setup interception of ALL logger logs would be nice… It would be nice to essentially switch over, monkeypatch and route all the logger logs via loguru 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
Intercepted Logging
A log interceptor for the logger L is a procedure that executes a thunk and returns two values: ... The optional arguments help...
Read more >Logging and intercepting database operations - EF6
The default logger logs command text (SQL), parameters, and the “Executing” line with a timestamp before the command is sent to the database....
Read more >Configuring the file system logger interceptor
The file system logger interceptor enables z/OS Connect users to log information about API and service requests in a file.
Read more >Logger Interceptor - Apache Struts
This interceptor logs the start and end of the execution an action (in English-only, not internationalized). Note: This interceptor will log at INFO...
Read more >Intercept Python Logging – the art of simplicity - Naoko Reeves
The problem: I need to ship specific log record and had formatter written in python. It is pretty complex transformation.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks a lot for sharing your solution, @pawamoy! 😃
From now on, I will systematically refer to your blog post as soon as an user asks for help to configure
loguru
withgunicorn
. 😃I posted a solution to intercept everything (gunicorn/uvicorn/httpx/etc.) here, hope this helps the next ones who want to do the same thing 🙂