Relative Content

Tag Archive for pythonlogging

Python logging filter works with console but still writes to file

I am saving the logs to a text file and displaying them to the console at the same time. I would like to apply a filter on the logs, so that some logs neither make it to the text file nor the console output. However, with this code, the logs that I would like to filter out are still being saved to the text file. The filter only seems to work on the console output.

Create new log file every time a function runs

I have a Python application that processes a credit card. I have logging set up for the full program but I would like to split the files so each time a function is called it would write a log file just for that function/transaction. This way I have each transaction logged and easily accessible without having to read through one long log file.

Add a “log” for a single function

I need to debug some legacy code and I only want to print some information to a file that will not disturb any other places in the codebase. The most crude way I have found so far is something like: