You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2. Support **correlation-id**[\[1\]](#1-what-is-correlation-idrequest-id)
22
22
3. Lightweight, no dependencies, minimal configuration needed (1 LoC to get it working)
23
23
4. Fully compatible with Python **logging** module. Support both Python 2.7.x and 3.x
24
-
5. Support HTTP request instrumentation. Built in support for [Flask](http://flask.pocoo.org/) & [Sanic](https://github.com/channelcat/sanic). Extensible to support other web frameworks. PR welcome :smiley: .
24
+
5. Support HTTP request instrumentation. Built in support for [Flask](http://flask.pocoo.org/) & [Sanic](https://github.com/channelcat/sanic) & [Quart](https://gitlab.com/pgjones/quart). Extensible to support other web frameworks. PR welcome :smiley: .
25
25
6. Support inject arbitrary extra properties to JSON log message.
26
26
27
27
# 2. Usage
28
28
Install by running this command:
29
29
> pip install json-logging
30
30
31
31
By default log will be emitted in normal format to ease the local development. To enable it on production set either **json_logging.ENABLE_JSON_LOGGING** or **ENABLE_JSON_LOGGING environment variable** to true.
32
-
32
+
33
33
To configure, call **json_logging.init(framework_name)**. Once configured library will try to configure all loggers (existing and newly created) to emit log in JSON format.
Current request correlation-id can be retrieved and pass to downstream services call as follow:
104
130
@@ -223,16 +249,16 @@ e.g.:
223
249
}
224
250
```
225
251
See following tables for detail format explanation:
226
-
- Common field
252
+
- Common field
227
253
228
254
Field | Description | Format | Example
229
255
--- | --- | --- | ---
230
-
written_at | The date when this log message was written. | ISO 8601 YYYY-MM-DDTHH:MM:SS.milliZ | 2017-12-23T15:14:02.208Z
256
+
written_at | The date when this log message was written. | ISO 8601 YYYY-MM-DDTHH:MM:SS.milliZ | 2017-12-23T15:14:02.208Z
231
257
written_ts | The timestamp in nano-second precision when this request metric message was written. | long number | 1456820553816849408
232
258
correlation_id | The timestamp in nano-second precision when this request metric message was written. | string | db2d002e-2702-41ec-66f5-c002a80a3d3f
233
-
type | Type of logging. "logs" or "request" | string |
259
+
type | Type of logging. "logs" or "request" | string |
234
260
component_id | Uniquely identifies the software component that has processed the current request | string | 9e6f3ecf-def0-4baf-8fac-9339e61d5645
235
-
component_name | A human-friendly name representing the software component | string | my-fancy-component
261
+
component_name | A human-friendly name representing the software component | string | my-fancy-component
236
262
component_instance | Instance's index of horizontally scaled service | string | 0
237
263
238
264
- application logs
@@ -245,7 +271,7 @@ thread | Identifies the execution thread in which this log message has been writ
245
271
logger | The logger name that emits the log message.
246
272
| string | requests-logger
247
273
248
-
- request logs:
274
+
- request logs:
249
275
250
276
Field | Description | Format | Example
251
277
--- | --- | --- | ---
@@ -267,7 +293,7 @@ referer | For HTTP requests, identifies the address of the webpage (i.e. the URI
267
293
x_forwarded_for | Comma-separated list of IP addresses, the left-most being the original client, followed by proxy server addresses that forwarded the client request. | string | 192.0.2.60,10.12.9.23
0 commit comments