question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intercepting logging logs

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
Delgancommented, Jun 9, 2020

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 with gunicorn. 😃

2reactions
pawamoycommented, Jun 3, 2020

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 🙂

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found