Forums

Logging works when I click "Run this file", but not from a console

Hi guys,

I am running a python script and want it to log to a file. When I am in the editing environment and click "Run this file", the file is successfully created and is being logged to.

When I start the script from a console however, the file is created but nothing is being logged to it. My file path is absolute:

file_name= "/home/RomaxVOFNL/Cat tree/" + cat_name +".log"

logging.basicConfig(handlers=[logging.FileHandler(logging_name, 'a', 'utf-8')], level=logging.INFO)

Does anyone know why this is occurring?

That does sound very strange. How are you running the file in a console -- is it a Bash console and you're running something like python3.7 myscript.py?