Acccess Jupyter Server Logs


I am using JupyterLab 3 in a Docker on a remote EC2 instance on AWS
I want to be able to see in the docker logs the requests made to the kernel - i.e. a log for each cell submission (hopefully with the code in it)
I am looking for a way to configure this using the file
Has anyone done something similar?


I believe the bit you’re looking for is Session.debug and the logging is produced from the jupyter_client package. This can be configured in the notebook config file using c.Session.debug = True or on the command line using --Session.debug=True.

This produces LOTS of logging which can contain potentially sensitive information - so please restrain its use to protected environments.

do i need a certain version for this to work?
I am using:


No, not that I’m aware. Here’s my env:

$ jupyter --version
jupyter core     : 4.7.1
jupyter-notebook : 6.4.3
qtconsole        : not installed
ipython          : 7.27.0
ipykernel        : 6.3.1
jupyter client   : 7.0.2
jupyter lab      : 3.1.1
nbconvert        : 6.1.0
ipywidgets       : not installed
nbformat         : 5.1.3
traitlets        : 5.1.0

and command line:
$ jupyter notebook --Session.debug=True --notebook-dir=~/notebooks/

and log output after starting a kernel:

[I 09:56:49.301 NotebookApp] Kernel started: 3aa544f4-a944-46fd-8bbf-755bdd48baf4, name: python3
{'content': {},
 'header': {'date': datetime.datetime(2021, 9, 1, 16, 56, 49, 382864, tzinfo=datetime.timezone.utc),
            'msg_id': '6cdf85db0a5f49e39b5cba964e7e03fb_8109_0',
            'msg_type': 'kernel_info_request',
            'session': '6cdf85db0a5f49e39b5cba964e7e03fb',
            'username': 'kbates',
            'version': '5.3'},
 'metadata': {},
 'msg_id': '6cdf85db0a5f49e39b5cba964e7e03fb_8109_0',
 'msg_type': 'kernel_info_request',
 'parent_header': {}}
 b'{"msg_id": "6cdf85db0a5f49e39b5cba964e7e03fb_8109_0", "msg_type": "kernel_in'
 b'fo_request", "username": "kbates", "session": "6cdf85db0a5f49e39b5cba964e7e0'
 b'3fb", "date": "2021-09-01T16:56:49.382864Z", "version": "5.3"}',

What output do you see in your terminal from which the server was started?

Ok so after a bit of testing, when I add the command line argument like you described --Session.debug=True I can see the logs like you show here,
But when I add this configuration in the file it does not show :open_mouth:

That’s odd. If I build my config file using jupyter notebook --generate-config, I have a section named Session(Configurable) configuration. I then modify the debug entry, to set the value to True:

## Debug output in the Session
#  Default: False
# c.Session.debug = False
c.Session.debug = True

and receive the desired logging using only jupyter notebook.

If your config file was not built that way, it shouldn’t matter, you just need the c.Session.debug = True entry. Note that the c. prefix matters within the python config file.

Got it to work, was my bad :slight_smile:

Can you tell me if adding this flag is production safe?

Also is there is any way to configure the debug logs? For example, write only data for cell execution and not kernel idle, etc.
The debug is a LOT of data