Skip to content

Commit 95b642a

Browse files
authored
Merge branch 'main' into moar-coverage
2 parents 9c57c30 + 830c87f commit 95b642a

File tree

6 files changed

+152
-12
lines changed

6 files changed

+152
-12
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ repos:
3030
files: \.py$
3131

3232
- repo: https://github.com/pre-commit/mirrors-mypy
33-
rev: v0.982
33+
rev: v0.990
3434
hooks:
3535
- id: mypy
3636
additional_dependencies: [types-requests]
@@ -47,7 +47,7 @@ repos:
4747
- id: mdformat
4848

4949
- repo: https://github.com/asottile/pyupgrade
50-
rev: v3.2.0
50+
rev: v3.2.2
5151
hooks:
5252
- id: pyupgrade
5353
args: [--py38-plus]
@@ -75,12 +75,7 @@ repos:
7575
- id: eslint
7676
stages: [manual]
7777

78-
- repo: https://github.com/sirosen/check-jsonschema
79-
rev: 0.18.4
78+
- repo: https://github.com/python-jsonschema/check-jsonschema
79+
rev: 0.19.1
8080
hooks:
81-
- id: check-jsonschema
82-
name: "Check GitHub Workflows"
83-
files: ^\.github/workflows/
84-
types: [yaml]
85-
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]
86-
stages: [manual]
81+
- id: check-github-workflows

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@
358358
# texinfo_no_detailmenu = False
359359

360360
intersphinx_mapping = {
361+
"python": ("https://docs.python.org/", None),
361362
"ipython": ("https://ipython.readthedocs.io/en/stable/", None),
362363
"nbconvert": ("https://nbconvert.readthedocs.io/en/latest/", None),
363364
"nbformat": ("https://nbformat.readthedocs.io/en/latest/", None),
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
.. _configurable_logging:
2+
3+
Configuring Logging
4+
===================
5+
6+
Jupyter Server (and Jupyter Server extension applications such as Jupyter Lab)
7+
are Traitlets applications.
8+
9+
By default Traitlets applications log to stderr. You can configure them to log
10+
to other locations e.g. log files.
11+
12+
Logging is configured via the ``logging_config`` "trait" which accepts a
13+
:py:func:`logging.config.dictConfig` object. For more information look for
14+
``Application.logging_config`` in :ref:`other-full-config`.
15+
16+
17+
Examples
18+
--------
19+
20+
.. _configurable_logging.jupyter_server:
21+
22+
Jupyter Server
23+
^^^^^^^^^^^^^^
24+
25+
A minimal example which logs Jupyter Server output to a file:
26+
27+
.. code-block:: python
28+
29+
c.ServerApp.logging_config = {
30+
'version': 1,
31+
'handlers': {
32+
'logfile': {
33+
'class': 'logging.FileHandler',
34+
'level': 'DEBUG',
35+
'filename': 'jupyter_server.log',
36+
},
37+
},
38+
'loggers': {
39+
'ServerApp': {
40+
'level': 'DEBUG',
41+
'handlers': ['console', 'logfile'],
42+
},
43+
},
44+
}
45+
46+
.. note::
47+
48+
To keep the default behaviour of logging to stderr ensure the ``console``
49+
handler (provided by Traitlets) is included in the list of handlers.
50+
51+
.. warning::
52+
53+
Be aware that the ``ServerApp`` log may contain security tokens. If
54+
redirecting to log files ensure they have appropriate permissions.
55+
56+
57+
.. _configurable_logging.extension_applications:
58+
59+
Jupyter Server Extension Applications (e.g. Jupyter Lab)
60+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61+
62+
An example which logs both Jupyter Server and Jupyter Lab output to a file:
63+
64+
.. note::
65+
66+
Because Jupyter Server and its extension applications are separate Traitlets
67+
applications their logging must be configured separately.
68+
69+
.. code-block:: python
70+
71+
c.ServerApp.logging_config = {
72+
'version': 1,
73+
'handlers': {
74+
'logfile': {
75+
'class': 'logging.FileHandler',
76+
'level': 'DEBUG',
77+
'filename': 'jupyter_server.log',
78+
'formatter': 'my_format',
79+
},
80+
},
81+
'formatters': {
82+
'my_format': {
83+
'format': '%(asctime)s %(levelname)-8s %(name)-15s %(message)s',
84+
'datefmt': '%Y-%m-%d %H:%M:%S',
85+
},
86+
},
87+
'loggers': {
88+
'ServerApp': {
89+
'level': 'DEBUG',
90+
'handlers': ['console', 'logfile'],
91+
},
92+
},
93+
}
94+
95+
c.LabApp.logging_config = {
96+
'version': 1,
97+
'handlers': {
98+
'logfile': {
99+
'class': 'logging.FileHandler',
100+
'level': 'DEBUG',
101+
'filename': 'jupyter_server.log',
102+
'formatter': 'my_format',
103+
},
104+
},
105+
'formatters': {
106+
'my_format': {
107+
'format': '%(asctime)s %(levelname)-8s %(name)-15s %(message)s',
108+
'datefmt': '%Y-%m-%d %H:%M:%S',
109+
},
110+
},
111+
'loggers': {
112+
'LabApp': {
113+
'level': 'DEBUG',
114+
'handlers': ['console', 'logfile'],
115+
},
116+
},
117+
}
118+
119+
.. note::
120+
121+
The configured application name should match the logger name
122+
e.g. ``c.LabApp.logging_config`` defines a logger called ``LabApp``.
123+
124+
.. tip::
125+
126+
This diff modifies the example to log Jupyter Server and Jupyter Lab output
127+
to different files:
128+
129+
.. code-block:: diff
130+
131+
--- before
132+
+++ after
133+
c.LabApp.logging_config = {
134+
'version': 1,
135+
'handlers': {
136+
'logfile': {
137+
'class': 'logging.FileHandler',
138+
'level': 'DEBUG',
139+
- 'filename': 'jupyter_server.log',
140+
+ 'filename': 'jupyter_lab.log',
141+
'formatter': 'my_format',
142+
},
143+
},

docs/source/operators/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ These pages are targeted at people using, configuring, and/or deploying multiple
1313
migrate-from-nbserver
1414
public-server
1515
security
16+
configuring-logging

jupyter_server/serverapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2292,7 +2292,7 @@ def shutdown_no_activity(self):
22922292
if len(km) != 0:
22932293
return # Kernels still running
22942294

2295-
if self.extension_manager.any_activity:
2295+
if self.extension_manager.any_activity():
22962296
return
22972297

22982298
seconds_since_active = (utcnow() - self.web_app.last_activity()).total_seconds()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ dependencies = [
4242
"Send2Trash",
4343
"terminado>=0.8.3",
4444
"tornado>=6.2.0",
45-
"traitlets>=5.1",
45+
"traitlets>=5.3.0",
4646
"websocket-client",
4747
"jupyter_events>=0.4.0"
4848
]

0 commit comments

Comments
 (0)