1
- JSON logging for Python [ ![ PyPi version] ( https://img.shields.io/pypi/v/json-logging-py.svg )] ( https://pypi.python.org/pypi/json-logging-py/ )
2
- ============
1
+ JSON logging for Python | PyPi version |
2
+ ======================================
3
3
4
- This library provides Python logging formatters to output JSON, 2 formatters are specific for Logstash message format version 0 or 1.
4
+ This library provides Python logging formatters to output JSON, 2
5
+ formatters are specific for Logstash message format version 0 or 1.
5
6
6
7
Installation
7
8
============
8
9
9
10
Using pip:
10
11
12
+ ::
13
+
11
14
pip install json-logging-py
12
15
13
16
From source:
14
17
18
+ ::
19
+
15
20
python setup.py install
16
21
17
22
Usage
18
23
=====
19
24
20
- The name of the library is ` jsonlogging ` , it provides 3 formatters:
25
+ The name of the library is ``jsonlogging ``, it provides 3 formatters:
26
+
27
+ JSONFormatter
28
+ -------------
21
29
22
- ### JSONFormatter
30
+ ::
23
31
24
32
{
25
33
"tags": [
@@ -34,7 +42,10 @@ The name of the library is `jsonlogging`, it provides 3 formatters:
34
42
"logger": "root"
35
43
}
36
44
37
- ### LogstashFormatterV0
45
+ LogstashFormatterV0
46
+ -------------------
47
+
48
+ ::
38
49
39
50
{
40
51
"@source": "JSON://server-01.example.com/example.py",
@@ -53,7 +64,10 @@ The name of the library is `jsonlogging`, it provides 3 formatters:
53
64
"@type": "JSON"
54
65
}
55
66
56
- ### LogstashFormatterV1
67
+ LogstashFormatterV1
68
+ -------------------
69
+
70
+ ::
57
71
58
72
{
59
73
"host": "server-01.example.com",
@@ -70,7 +84,10 @@ The name of the library is `jsonlogging`, it provides 3 formatters:
70
84
"levelname": "ERROR"
71
85
}
72
86
73
- ### Python example
87
+ Python example
88
+ --------------
89
+
90
+ ::
74
91
75
92
import logging
76
93
import jsonlogging
@@ -91,3 +108,6 @@ The name of the library is `jsonlogging`, it provides 3 formatters:
91
108
92
109
# You can pass additional tags
93
110
logger.error('hello world!', extra={"tags": ["hello=world"]})
111
+
112
+ .. |PyPi version | image :: https://img.shields.io/pypi/v/json-logging-py.svg
113
+ :target: https://pypi.python.org/pypi/json-logging-py/
0 commit comments