Ability to log the file details when we upload a file to notebook

Hi All, I am trying to capture the file details whenever a file is uploaded to JupyterHub Notebook for audit purposes. Is there an ability in JupyterHub to capture the user who uploaded the file, file type, file size and file name details?

Any options available?

Jupyter server already logs uploads. For example:

[I 2024-06-25 10:19:53.203 ServerApp] Uploading file to /work/foo.py
[W 2024-06-25 10:19:58.037 ServerApp] delete /work/foo.py

Each user’s singleuser server will have its own log stream. The location of the logs depends on your JupyterHub configuration, e.g. if you’re using DockerSpawner the logs will be handled by Docker, and will include the container name, which by default is derived from the username.

You could potentially extend jupyter-server to log more information about files.

1 Like

Thank you for the reply. This really helped!

I am able to capture the upload logs at directory level for example "upload_dir = ‘/mnt/user/test_folder’. How can I capture logs at root i.e., ‘/mnt/user’?

1 Like

Can you clarify what you mean? If I upload a file to the top-level of the JupyterLab filesystem I see the log:

[I 2024-06-28 19:31:44.373 ServerApp] Uploading file to /foo.py