Search code examples
jupyter-notebookjupyter

How to enable and access debug logging for notebook and IPython kernel


I'm doing a small research on IPython kernel and trying to get debug logs out of it and see how it interacts with a notebook. Now it looks like the documentation and example configs shipped in my distribution is totally outdated.

The questions

  1. Where the ipython kernel log files are located?
  2. How can I enable DEBUG level logging in both jupyter notebook and ipython kernel?

What I've tried

Please read this section before giving links to the official docs

First I created profiles for both IPython and notebook with the following commands:

$ ipython profile create
$ jupyter notebook --generate-config

As expected three files where created:

  • .jupyter/jupyter_notebook_config.py
  • .ipython/profile_default/ipython_config.py
  • .ipython/profile_default/ipython_kernel_config.py

In these files I found similar commented fragments:

 # Set the log level by value or name.
 # c.Application.log_level = 0

I tried to uncomment it in the jupyter config. Instead of adding more details it totally disabled console output for the jupyter process. I also tried value 50 it has the same result, value DEBUG gave me Python error on start.

I also played with these values in ipython's configs but I wasn't able to find log files location.

In mail list command line option --log-level=DEBUG is mentioned and indeed it works for jupyter. But I really want to persist this setting in a profile and have debug info for the kernel too.

Config options NotebookApp.log_level and IPKernelApp.log_level also change nothing.


Solution

  • I believe that this kind of functionality is still on the wishlist:

    https://github.com/ipython/ipython/issues/8570

    But you could try something like this:

    jupyter notebook --debug > log.file 2>&1
    

    or

    ipykernel kernel --debug > log.file 2>&1