When I running the following inside IPython Notebook I don't see any output:
import logging
logging.basicConfig(level=logging.DEBUG)
logging.debug("test")
Anyone know how to make it so I can see the "test" message inside the notebook?
When I running the following inside IPython Notebook I don't see any output:
import logging
logging.basicConfig(level=logging.DEBUG)
logging.debug("test")
Anyone know how to make it so I can see the "test" message inside the notebook?
Bear in mind that stderr is the default stream for the
logging
module, so in IPython and Jupyter notebooks you might not see anything unless you configure the stream to stdout:My understanding is that the IPython session starts up logging so basicConfig doesn't work. Here is the setup that works for me (I wish this was not so gross looking since I want to use it for almost all my notebooks):
Now when I run:
I get a "mylog.log" file in the same directory as my notebook that contains:
Note that if you rerun this without restarting the IPython session it will write duplicate entries to the file since there would now be two file handlers defined
Try following:
According to logging.basicConfig:
It seems like ipython notebook call basicConfig (or set handler) somewhere.
If you still want to use
basicConfig
, reload the logging module like thisYou can configure logging by running
%config Application.log_level="INFO"
For more information, see IPython kernel options
What worked for me now (Jupyter, notebook server is: 5.4.1, IPython 7.0.1)
Now I can use logger to print info, otherwise I would see only message from the default level (
logging.WARNING
) or above.