My intention is to
- log into a file in great detail and verbose formatting (timestamp, logger name, etc.).
- log into the Python Interactor in less verbose mode (less verbose formatting, only higher logging levels, etc.).
This can be achieved by defining two handlers in the logging module of Python: a FileHandler and a StreamHandler. I tested logging into a file; it works as intended outside 3D Slicer. Before adding the possibility of logging into the console, I tried it out in 3D Slicer.
I noticed that my INFO-level messages automatically appear in the Python Interactor, even though I only log into a file. This is not the intended behaviour for me as
- I don’t want my logs appearing automatically in the Python Interactor.
- I will define my own formatting to be shown in the Python Interactor using a StreamHandler object.
It seems that the logs I send to the file are automatically redirected to the Python Interactor, filtered (DEBUG level messages are not shown for instance) and reformatted (keeps the message only) by Slicer. How can I switch this behaviour off?
I also noted that my logs appear in the Error Log window too (this time, the level is indicated as well). It is less of a problem for me, although, if possible, I would like to switch off the automatic redirection here as well.
What I want to achieve:
- my logging into a file (using FileHandler) is not shown in the Python Interactor (preferably neither in the Error Log window)
- my logs with a StreamHandler are shown in the Python Interactor.