Closed lastboy closed 3 years ago
Hi - sorry for the delay, I'll take a look at this in an hour or 2 :)
Ok, should be fixed in v0.3.17.
I faced the same issue with some 3rd party modules containing objects that could not be serialized. To get around this i added a custom JSONEncoder, which returns a string for these exceptions, and used it in my logging setup:
json_extensions.py
import json
class LoggingJSONEncoder(json.JSONEncoder):
def default(self, obj):
try:
return json.JSONEncoder.default(self, obj)
except:
return str(obj)
app.py
import seqlog
seqlog.log_to_seq(
server_url="http://my-seq-server:5341/",
api_key="My API Key",
level=logging.INFO,
batch_size=10,
auto_flush_timeout=10,
override_root_logger=True,
json_encoder_class=json_extensions.LoggingJSONEncoder
)
duplicate of #13. Closing.
Description
I have configured logging from a file using seqlog docs
What I Did
All is working as expected until I switched from LEVEL INFO to DEBUG. I got a JSON parse error: "TypeError: Object of type bytes is not JSON serializable", probably about some third-party log.
I modified the code at structured_logging.py file and caught the exception on the statement: ...json.dumps(request_body... and just returned an empty Events so the seqlog could continue w/o an exception.
Please suggest...
Thank you, -Arik