Skip to content

Commit 153ce69

Browse files
committed
Add opt-in debug logging configuration for Jupyter server
Adds configurable debug logging to help troubleshoot kernel communication and server issues without impacting production performance. Changes: - Add environment variable-based debug logging configuration - Make Application.log_level conditional (DEBUG or INFO) - Add enhanced logging_config for tornado, jupyter_server, and jupyter_client - Add opt-in Session.debug for ZMQ message flow logging - Add environment variable documentation to README.md All features are opt-in via environment variables: - DEEPNOTE_ENABLE_DEBUG_LOGGING: Enables DEBUG-level logs (default: false/INFO) - DEEPNOTE_ENABLE_ZMQ_DEBUG: Enables ZMQ message debugging (default: false) This ensures production-safe defaults with no performance impact when disabled.
1 parent 9994c8f commit 153ce69

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,31 @@ deepnote-toolkit config set server.jupyter_port 9000
6363

6464
**Security note**: The CLI will warn if Jupyter runs without authentication. For local development only. Set `DEEPNOTE_JUPYTER_TOKEN` for shared environments.
6565

66+
## Environment Variables
67+
68+
### Debugging and Logging
69+
70+
The following environment variables control debug logging and diagnostic output:
71+
72+
- **`DEEPNOTE_ENABLE_DEBUG_LOGGING`**: Set to `true` to enable verbose DEBUG-level logs for tornado, jupyter_server, and jupyter_client. This increases log verbosity which can help troubleshoot server-related issues. Default: `false` (INFO level)
73+
74+
- **`DEEPNOTE_ENABLE_ZMQ_DEBUG`**: Set to `true` to enable detailed ZMQ message flow logging for kernel communication debugging. This logs all messages exchanged between the Jupyter server and kernel, which is useful for diagnosing stuck execution or kernel communication issues. Default: `false`
75+
76+
**Example Usage**:
77+
78+
```bash
79+
# Enable debug logging
80+
DEEPNOTE_ENABLE_DEBUG_LOGGING=true deepnote-toolkit server
81+
82+
# Enable ZMQ message debugging
83+
DEEPNOTE_ENABLE_ZMQ_DEBUG=true deepnote-toolkit server
84+
85+
# Enable both
86+
DEEPNOTE_ENABLE_DEBUG_LOGGING=true DEEPNOTE_ENABLE_ZMQ_DEBUG=true deepnote-toolkit server
87+
```
88+
89+
**Note**: Debug logging can significantly increase log volume and may impact performance. Only enable in development or when troubleshooting specific issues.
90+
6691
## Need help?
6792

6893
- Join our [Community](https://github.com/deepnote/deepnote/discussions)!

deepnote_core/resources/jupyter/jupyter_server_config.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
# do not import explicitly it will break the config loading
1111
c = get_config() # pylint: disable=E0602; # noqa: F821
1212

13+
# Environment variable-based debug logging configuration
14+
# Set DEEPNOTE_ENABLE_DEBUG_LOGGING=true to enable verbose DEBUG logs
15+
# Set DEEPNOTE_ENABLE_ZMQ_DEBUG=true to enable detailed ZMQ message logging
16+
debug_logging_enabled = os.getenv("DEEPNOTE_ENABLE_DEBUG_LOGGING", "false").lower() == "true"
17+
log_level = "DEBUG" if debug_logging_enabled else "INFO"
1318

1419
# ------------------------------------------------------------------------------
1520
# Application(SingletonConfigurable) configuration
@@ -27,7 +32,8 @@
2732
## Set the log level by value or name.
2833
# Choices: any of [0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']
2934
# Default: 30
30-
c.Application.log_level = 10
35+
# Conditional based on DEEPNOTE_ENABLE_DEBUG_LOGGING environment variable
36+
c.Application.log_level = 10 if debug_logging_enabled else 20 # DEBUG or INFO
3137

3238
## Configure additional log handlers.
3339
#
@@ -414,7 +420,15 @@
414420

415421
##
416422
# See also: Application.logging_config
417-
# c.ServerApp.logging_config = {}
423+
# Enhanced logging configuration for debugging
424+
# Uses debug_logging_enabled and log_level variables defined at the top of this file
425+
c.ServerApp.logging_config = {
426+
"loggers": {
427+
"tornado.access": {"level": log_level},
428+
"jupyter_server.serverapp": {"level": log_level},
429+
"jupyter_client.session": {"level": log_level},
430+
}
431+
}
418432

419433
## The login handler class to use.
420434
# Default: 'notebook.auth.login.LoginHandler'
@@ -820,7 +834,10 @@
820834

821835
## Debug output in the Session
822836
# Default: False
823-
# c.Session.debug = False
837+
# Enable ZMQ message flow debugging for troubleshooting kernel communication
838+
# Set DEEPNOTE_ENABLE_ZMQ_DEBUG=true to enable detailed ZMQ message logging
839+
if os.getenv("DEEPNOTE_ENABLE_ZMQ_DEBUG", "false").lower() == "true":
840+
c.Session.debug = True
824841

825842
## The maximum number of digests to remember.
826843
#

0 commit comments

Comments
 (0)