Releases: nhairs/python-json-logger
Releases · nhairs/python-json-logger
4.0.0
4.0.0 - 2025-10-06
Added
- Support
DictConfiguratorprefixes forrename_fieldsandstatic_fields. #45- Allows using values like
ext://sys.stderrinfileConfig/dictConfigvalue fields.
- Allows using values like
- Support comma seperated lists for Formatter
fmt(style=",") e.g."asctime,message,levelname"#15- Note that this style is specific to
python-json-loggerand thus care should be taken not to pass this format to other logging Formatter implementations.
- Note that this style is specific to
- Supports sequences of strings (e.g. lists and tuples) of field names for Formatter
fmt. #16
Changed
- Rename
pythonjsonlogger.core.LogRecordandlog_recordarguments to avoid confusion / overlapping withlogging.LogRecord. #38- Affects arguments to
pythonjsonlogger.core.BaseJsonFormatter(and any child classes).serialize_log_recordadd_fieldsjsonify_log_recordprocess_log_record
- Note: functions referring to
log_recordhave not had their function name changed.
- Affects arguments to
Removed
- Remove support for providing strings instead of objects when instantiating formatters. Instead use the
DictConfiguratorext://prefix format when usingfileConfig/dictConfig. #47- Affects
pythonjsonlogger.json.JsonFormatter:json_default,json_encoder,json_serializer. - Affects
pythonjsonlogger.orjson.OrjsonFormatter:json_default. - Affects
pythonjsonlogger.msgspec.MsgspecFormatter:json_default.
- Affects
Thanks @rubensa
v4.0.0.rc1
4.0.0.rc1 - 2025-09-07
Added
- Support
DictConfiguratorprefixes forrename_fieldsandstatic_fields. #45- Allows using values like
ext://sys.stderrinfileConfig/dictConfigvalue fields.
- Allows using values like
- Support comma seperated lists for Formatter
fmt(style=",") e.g."asctime,message,levelname"#15- Note that this style is specific to
python-json-loggerand thus care should be taken not to pass this format to other logging Formatter implementations.
- Note that this style is specific to
- Supports sequences of strings (e.g. lists and tuples) of field names for Formatter
fmt. #16
Changed
- Rename
pythonjsonlogger.core.LogRecordandlog_recordarguments to avoid confusion / overlapping withlogging.LogRecord. #38- Affects arguments to
pythonjsonlogger.core.BaseJsonFormatter(and any child classes).serialize_log_recordadd_fieldsjsonify_log_recordprocess_log_record
- Note: functions referring to
log_recordhave not had their function name changed.
- Affects arguments to
Removed
- Remove support for providing strings instead of objects when instantiating formatters. Instead use the
DictConfiguratorext://prefix format when usingfileConfig/dictConfig. #47- Affects
pythonjsonlogger.json.JsonFormatter:json_default,json_encoder,json_serializer. - Affects
pythonjsonlogger.orjson.OrjsonFormatter:json_default. - Affects
pythonjsonlogger.msgspec.MsgspecFormatter:json_default.
- Affects
Thanks @rubensa
3.3.0
3.3.0 - 2025-03-06
Added
exc_info_as_arrayandstack_info_as_arrayoptions are added topythonjsonlogger.core.BaseJsonFormatterallowing both to be encoded as list of lines instead of a single multi-line string. #35
Security
- Remove
msgspec-python313-prefromdevdependencies preventing potential RCE. Details: GHSA-wmxh-pxcx-9w24
Thanks @1hakusai1 and @omnigodz
3.2.1
3.2.0
3.2.0 - 2024-12-11
Changed
pythonjsonlogger.[ORJSON,MSGSPEC]_AVAILABLEno longer imports the respective package when determining availability.pythonjsonlogger.[orjson,msgspec]now throws apythonjsonlogger.exception.MissingPackageErrorwhen required libraries are not available. These contain more information about what is missing whilst still being anImportError.defaultsparameter is no longer ignored and now conforms to the standard library. Setting a defaults dictionary will add the specified keys if the those keys do not exist in a record or weren't passed by theextraparameter when logging a message.typing_extensionsis only installed on Python version < 3.10.- Support Python 3.13
msgspechas only been tested against pre-release versions.
v3.1.0
3.1.0 - 2023-05-28
This splits common funcitonality out to allow supporting other JSON encoders. Although this is a large refactor, backwards compatibility has been maintained.
Added
pythonjsonlogger.core- more details below.pythonjsonlogger.defaultsmodule that provides many functions for handling unsupported types.- Orjson encoder support via
pythonjsonlogger.orjson.OrjsonFormatterwith the following additions:- bytes are URL safe base64 encoded.
- Exceptions are "pretty printed" using the exception name and message e.g.
"ValueError: bad value passed" - Enum values use their value, Enum classes now return all values as a list.
- Tracebacks are supported
- Classes (aka types) are support
- Will fallback on
__str__if available, else__repr__if available, else will use__could_not_encode__
- MsgSpec encoder support via
pythonjsonlogger.msgspec.MsgspecFormatterwith the following additions:- Exceptions are "pretty printed" using the exception name and message e.g.
"ValueError: bad value passed" - Enum classes now return all values as a list.
- Tracebacks are supported
- Classes (aka types) are support
- Will fallback on
__str__if available, else__repr__if available, else will use__could_not_encode__ - Note: msgspec only supprts enum values of type
intorstrjcrist/msgspec#680
- Exceptions are "pretty printed" using the exception name and message e.g.
Changed
pythonjsonlogger.jsonloggerhas been moved topythonjsonlogger.jsonwith core functionality moved topythonjsonlogger.core.pythonjsonlogger.core.BaseJsonFormatterproperly supports alllogging.Formatterarguments:fmtis unchanged.datefmtis unchanged.stylecan now support non-standard arguments by settingvalidatetoFalsevalidateallows non-standardstylearguments or prevents callingvalidateon standardstylearguments.defaultis ignored.
pythonjsonlogger.json.JsonFormatterdefault encodings changed:- bytes are URL safe base64 encoded.
- Exception formatting detected using
BaseExceptioninstead ofException. Now "pretty prints" the exception using the exception name and message e.g."ValueError: bad value passed" - Dataclasses are now supported
- Enum values now use their value, Enum classes now return all values as a list.
- Will fallback on
__str__if available, else__repr__if available, else will use__could_not_encode__
- Renaming fields now preserves order (#7) and ignores missing fields (#6).
- Documentation
- Generated documentation using
mkdocsis stored indocs/ - Documentation within
README.mdhas been moved todocs/index.mdanddocs/qucikstart.md. CHANGELOG.mdhas been moved todocs/change-log.mdSECURITY.mdhas been moved and replaced with a symbolic link todocs/security.md.
- Generated documentation using
Deprecated
pythonjsonlogger.jsonloggeris nowpythonjsonlogger.jsonpythonjsonlogger.jsonlogger.RESERVED_ATTRSis nowpythonjsonlogger.core.RESERVED_ATTRS.pythonjsonlogger.jsonlogger.merge_record_extrais nowpythonjsonlogger.core.merge_record_extra.
Removed
- Python 3.7 support dropped
pythonjsonlogger.jsonlogger.JsonFormatter._str_to_fnreplaced withpythonjsonlogger.core.str_to_object.
v3.1.0.rc3
3.1.0.rc3 - 2023-05-03
This splits common funcitonality out to allow supporting other JSON encoders. Although this is a large refactor, backwards compatibility has been maintained.
Added
.core- more details below..defaultsmodule that provides many functions for handling unsupported types.- Orjson encoder support via
.orjson.OrjsonFormatterwith the following additions:- bytes are URL safe base64 encoded.
- Exceptions are "pretty printed" using the exception name and message e.g.
"ValueError: bad value passed" - Enum values use their value, Enum classes now return all values as a list.
- Tracebacks are supported
- Classes (aka types) are support
- Will fallback on
__str__if available, else__repr__if available, else will use__could_not_encode__
- MsgSpec encoder support via
.msgspec.MsgspecFormatterwith the following additions:- Exceptions are "pretty printed" using the exception name and message e.g.
"ValueError: bad value passed" - Enum classes now return all values as a list.
- Tracebacks are supported
- Classes (aka types) are support
- Will fallback on
__str__if available, else__repr__if available, else will use__could_not_encode__ - Note: msgspec only supprts enum values of type
intorstrjcrist/msgspec#680
- Exceptions are "pretty printed" using the exception name and message e.g.
Changed
.jsonloggerhas been moved to.jsonwith core functionality moved to.core..core.BaseJsonFormatterproperly supports alllogging.Formatterarguments:fmtis unchanged.datefmtis unchanged.stylecan now support non-standard arguments by settingvalidatetoFalsevalidateallows non-standardstylearguments or prevents callingvalidateon standardstylearguments.defaultis ignored.
.json.JsonEncoderdefault encodings changed:- bytes are URL safe base64 encoded.
- Exception formatting detected using
BaseExceptioninstead ofException. Now "pretty prints" the exception using the exception name and message e.g."ValueError: bad value passed" - Dataclasses are now supported
- Enum values now use their value, Enum classes now return all values as a list.
- Will fallback on
__str__if available, else__repr__if available, else will use__could_not_encode__
- Renaming fields now preserves order (#7) and ignores missing fields (#6).
Deprecated
.jsonloggeris now.json.jsonlogger.RESERVED_ATTRSis now.core.RESERVED_ATTRS..jsonlogger.merge_record_extrais now.core.merge_record_extra.
Removed
- Python 3.7 support dropped
.jsonlogger.JsonFormatter._str_to_fnreplaced with.core.str_to_object.
v3.1.0.rc2
3.1.0.rc2 - 2023-05-03
This splits common funcitonality out to allow supporting other JSON encoders. Although this is a large refactor, backwards compatibility has been maintained.
Added
.core- more details below..defaultsmodule that provides many functions for handling unsupported types.- Orjson encoder support via
.orjson.OrjsonFormatterwith the following additions:- bytes are URL safe base64 encoded.
- Exceptions are "pretty printed" using the exception name and message e.g.
"ValueError: bad value passed" - Enum values use their value, Enum classes now return all values as a list.
- Tracebacks are supported
- Classes (aka types) are support
- Will fallback on
__str__if available, else__repr__if available, else will use__could_not_encode__
- MsgSpec encoder support via
.msgspec.MsgspecFormatterwith the following additions:- Exceptions are "pretty printed" using the exception name and message e.g.
"ValueError: bad value passed" - Enum classes now return all values as a list.
- Tracebacks are supported
- Classes (aka types) are support
- Will fallback on
__str__if available, else__repr__if available, else will use__could_not_encode__ - Note: msgspec only supprts enum values of type
intorstrjcrist/msgspec#680
- Exceptions are "pretty printed" using the exception name and message e.g.
Changed
.jsonloggerhas been moved to.jsonwith core functionality moved to.core..core.BaseJsonFormatterproperly supports alllogging.Formatterarguments:fmtis unchanged.datefmtis unchanged.stylecan now support non-standard arguments by settingvalidatetoFalsevalidateallows non-standardstylearguments or prevents callingvalidateon standardstylearguments.defaultis ignored.
.json.JsonEncoderdefault encodings changed:- bytes are URL safe base64 encoded.
- Exception formatting detected using
BaseExceptioninstead ofException. Now "pretty prints" the exception using the exception name and message e.g."ValueError: bad value passed" - Dataclasses are now supported
- Enum values now use their value, Enum classes now return all values as a list.
- Will fallback on
__str__if available, else__repr__if available, else will use__could_not_encode__
Deprecated
.jsonloggeris now.json.jsonlogger.RESERVED_ATTRSis now.core.RESERVED_ATTRS..jsonlogger.merge_record_extrais now.core.merge_record_extra.
Removed
- Python 3.7 support dropped
.jsonlogger.JsonFormatter._str_to_fnreplaced with.core.str_to_object.
v3.1.0.rc1
3.1.0.rc1 - 2023-05-03
This splits common funcitonality out to allow supporting other JSON encoders. Although this is a large refactor, backwards compatibility has been maintained.
Added
.core- more details below.- Orjson encoder support via
.orjson.OrjsonFormatter. - MsgSpec encoder support via
.msgspec.MsgspecFormatter.
Changed
.jsonloggerhas been moved to.jsonwith core functionality moved to.core..core.BaseJsonFormatterproperly supports alllogging.Formatterarguments:fmtis unchanged.datefmtis unchanged.stylecan now support non-standard arguments by settingvalidatetoFalsevalidateallows non-standardstylearguments or prevents callingvalidateon standardstylearguments.defaultis ignored.
Deprecated
.jsonloggeris now.json.jsonlogger.RESERVED_ATTRSis now.core.RESERVED_ATTRS..jsonlogger.merge_record_extrais now.core.merge_record_extra.
Removed
- Python 3.7 support dropped
.jsonlogger.JsonFormatter._str_to_fnreplaced with.core.str_to_object.