Writing to jupyter lab logs from notebook

Hiya,

When I start jupyter lab interactively I get a bunch of logs in the terminal, eg:

[I 2021-09-22 10:54:01.664 ServerApp] jupyterlab | extension was successfully linked.
[I 2021-09-22 10:54:01.678 ServerApp] Writing Jupyter server cookie secret to /home/compute/.local/share/jupyter/runtime/jupyter_cookie_secret
[I 2021-09-22 10:54:01.901 ServerApp] nbclassic | extension was successfully linked.
[I 2021-09-22 10:54:01.924 ServerApp] nbclassic | extension was successfully loaded.
[I 2021-09-22 10:54:01.925 LabApp] JupyterLab extension loaded from /home/compute/code/.venv/lib/python3.7/site-packages/jupyterlab
[I 2021-09-22 10:54:01.925 LabApp] JupyterLab application directory is /home/compute/code/.venv/share/jupyter/lab
[I 2021-09-22 10:54:01.929 ServerApp] jupyterlab | extension was successfully loaded.
[I 2021-09-22 10:54:01.930 ServerApp] Serving notebooks from local directory: /home/compute/code
[I 2021-09-22 10:54:01.930 ServerApp] Jupyter Server 1.11.0 is running at:
....

I have another process monitoring these logs in the terminal.
So I was wondering, is it possible to write to these logs from a notebook?

Not really with the built-in tools. These logs are from the server process, but your notebook is talking to the kernel process.

Of course, you could implement a server extension and JupyterLab extension pair that would enable you to send messages from the frontend to the server that could be put in the logs.

2 Likes