mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 08:05:53 +03:00
[GH-ISSUE #616] JSON Encode Failed #218
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#218
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @austinh on GitHub (Jul 24, 2015).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/616
JSON encoding failed: Malformed UTF-8 characters, possibly incorrectly encoded. Encoding: array (
I upgraded my symfony composer files lately, and got this error. This does not happen in 1.14.0. The latest change in "Fixed JSON encoding errors being silently suppressed (PHP 5.5+ only)" caused this error.
I am using this in conjunction with SNCRedis Bundle to store sessions in redis.
Is there any way sncredisbundle can utf8_encode the log message?
The session is saved fine and everything else works, its purely the logging.
I have also created a bug at SncRedisBundle git because it may be an issue with their code.
@Seldaek commented on GitHub (Jul 30, 2015):
I believe this is usually indicating a malformed UTF-8 message yes, but maybe I made a mistake, can you link to that SncRedis issue?
@austinh commented on GitHub (Jul 30, 2015):
https://github.com/snc/SncRedisBundle/issues/193
@ckmaresca commented on GitHub (Aug 12, 2015):
I don't know if this is relevant, but there are a bunch of options that you can use with
json_encodeto deal with odd characters that cause encoding to fail. They are described here: http://php.net/manual/en/json.constants.php - specificallyJSON_HEX_*andJSON_UNESCAPED_*I would note that this is a pain in PHP as it's not obvious that you need these options for things to work and
json_encodehas a habit of failing silently with no exception to trap....@Seldaek commented on GitHub (Nov 18, 2015):
I'm gonna assume this gets fixed by https://github.com/Seldaek/monolog/pull/683 as there is no clear repro case I can't verify but it most likely is covered too.
@ckmaresca for the record, JSON_HEX and JSON_UNESCAPED do nothing to prevent these errors unfortunately, they merely tweak the way things are encoded by default, but that only concerns valid UTF-8 strings. Non-UTF-8 can not be encoded to json as the format mandates Unicode strings.