Modify logging format from imported module?
See original GitHub issueHi there.
I hope you don’t mind me posting another issue I have? I currently import a 3rd party package which produces quite a bit of log outputs. Is it possible to pipe this into Loguru and make it adhere to my defined log formatting? I don’t want to filter or disable it but change appearance…
Here are a couple of lines to illustrate it (last one is from my script and the desired format for all logs):
[2020-09-18 12:43:59,032][wetterdienst.data_collection][INFO] - No files found for precipitation/hourly/recent/station_id_2542. Station will be skipped.
[2020-09-18 12:43:59,065][wetterdienst.api][INFO] - Combination for precipitation/hourly/PeriodType.NOW does not exist and is skipped.
20-09-18 12:43:59.3 | WARNING | preprocess.py.main:89 - Only using 2 stations for now (target, source): [2290, 2542]
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
how to modify python logging module name in formatter
1. in your format, you're specifying the logger name [%(name)s] . you can set your logger name to whatever you want, for example...
Read more >Logging Cookbook — Python 3.11.1 documentation
Here is a slight modification to the previous simple module-based configuration example: import logging logger = logging.getLogger('simple_example') logger.
Read more >How to Collect, Customize, and Centralize Python Logs
Once you modify your log format to include the logger name ( %(name)s ) ... uppermodule.py import logging import lowermodule logging.
Read more >A Step-by-Step Guide to Python Logging - Pylenin
In this article, you will learn about python logging module for logging events and why logging is better than print.
Read more >Python Logging Guide - Best Practices and Hands-on Examples
The specifications for the logging configuration format are found in the Python standard library. ... Line 1: import the logging module.
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
Excellent!
wetterdienst_logger.propagate = False
seems to do the trick 👍Thanks for taking the time to guide me through the depths of python logging 😄
Maybe by adding
wetterdienst_logger.propagate = False
. 🤔Otherwise, just remove all handlers. 😁