0
votes

I'm having a problem with logging in Spyder.

My code has some important output like a progressbar and some logging. I don't want the logging to be in the IPython console output, just in the log file.

There is a logging.conf file because i need the TimedRotatingFileHandler and a formatter.

The code looks like this

print('sth important')
logger.info('first print worked')
print('just sth')

I want the output to be like

sth important
just sth

and the logfile "output.log"

date - INFO - first print worked

The Problem is: When I set the logger & handler level in .conf to INFO, the output in the IPython console is

sth important
date - INFO - first print worked
just sth

logger level WARNING, handler level INFO: neither output in console nor file

logger level INFO, handler level WARNING: output in console, "output.log" empty

In the python.org logging tutorial this works with logging.basicConfig, but how can I combine this with handlers and formatters?

1

1 Answers

0
votes

There seems to be a problem with the timedRotatingHandler. It works fine with the FileHandler. Just rename the logfile with the datetime and os packages. This may not be the best solution but at least it is working.