Relative Content

Tag Archive for pythonlogging

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:

Can someone explain the ‘levels’ in the Python Logging module and whether Loggin can be setup in a def function?

I am fairly new to Python and now trying to use Logging rather that Print to follow and debug my code. The problem is that I am trying to setup Logging parameters using a def inline function and it is not working. I am using def because the parameter list is long and can be reused.
However by trial and error (definitely not by understanding!) I find that the following code works: