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

Commit f3ca54b

Browse files
author
Zakaria Zajac
authored
Merge branch 'master' into python2.6-test-fix-and-travis-ci
2 parents 7bfd7ae + 7cb0792 commit f3ca54b

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ python:
88
- "3.4"
99
install: pip install tox-travis
1010
script: tox
11-

README.markdown

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

64+
With a Config File
65+
------------------
66+
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.
67+
68+
[loggers]
69+
keys = root,custom
70+
71+
[logger_root]
72+
handlers =
73+
74+
[logger_custom]
75+
level = INFO
76+
handlers = custom
77+
qualname = custom
78+
79+
[handlers]
80+
keys = custom
81+
82+
[handler_custom]
83+
class = StreamHandler
84+
level = INFO
85+
formatter = json
86+
args = (sys.stdout,)
87+
88+
[formatters]
89+
keys = json
90+
91+
[formatter_json]
92+
format = %(message)s
93+
class = pythonjsonlogger.jsonlogger.JsonFormatter
94+
6495
Example
6596
=======
6697

src/pythonjsonlogger/jsonlogger.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def format(self, record):
124124
# user-supplied dict.
125125
if record.exc_info and not message_dict.get('exc_info'):
126126
message_dict['exc_info'] = self.formatException(record.exc_info)
127+
if not message_dict.get('exc_info') and record.exc_text:
128+
message_dict['exc_info'] = record.exc_text
127129

128130
try:
129131
log_record = OrderedDict()

0 commit comments

Comments
 (0)