How to log JupyterLab console output to a file?

Is there a way to hook up a file handler in the JupyterLab configuration file in order to log all of the console output of JuptyerLab to a file? I’ve tried several approaches and none of them seem to capture everything that we would normally see when we watch the log output in a console after JupyterLab starts. Some of the approaches I have tried (e.g., hooking up a filehandler to the Traitlets logger) only capture a subset of the log output. I am looking for an approach that would capture everything that we normally see in the console when JupyterLab starts. Specifically, I am looking for errors generated by server extensions. If one of my server extensions throws, I would like to see the error.

My server extensions are running in an environment, that I have little control over; hence the problem of trying to get to this log information.

1 Like

I thought that perhaps just adding a FileHandler to the root logger would pick up that output in the console, but that doesn’t seem to work.