Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Commit 47c38b7

Browse files
author
Zakaria Zajac
authored
Merge pull request #37 from eelsweb/patch-1
Added documentation for use with fileConfig
2 parents 6425c16 + 5d044b5 commit 47c38b7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.markdown

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,37 @@ For custom handling of object serialization you can specify default json object
5959
logger.info("classic message", extra={"special": "value", "run": 12})
6060
```
6161

62+
With a Config File
63+
------------------
64+
To use the module with a config file using the [`fileConfig` function](https://docs.python.org/3/library/logging.config.html#logging.config.fileConfig), use the class `pythonjsonlogger.jsonlogger.JsonFormatter`. Here is a sample config file.
65+
66+
[loggers]
67+
keys = root,custom
68+
69+
[logger_root]
70+
handlers =
71+
72+
[logger_custom]
73+
level = INFO
74+
handlers = custom
75+
qualname = custom
76+
77+
[handlers]
78+
keys = custom
79+
80+
[handler_custom]
81+
class = StreamHandler
82+
level = INFO
83+
formatter = json
84+
args = (sys.stdout,)
85+
86+
[formatters]
87+
keys = json
88+
89+
[formatter_json]
90+
format = %(message)s
91+
class = pythonjsonlogger.jsonlogger.JsonFormatter
92+
6293
Example
6394
=======
6495

0 commit comments

Comments
 (0)