PHP Syslog Patch for Windows (2)
We published a patch that makes PHP to send UTF-8 strings to eventlog on Windows. It works well, but the patch is only applicable when your PHP's 'mbstring.internal_encoding' is UTF-8. This means there are some limitations against general use.
We have improved that patch by introducing a new INI directive that enables/disables wide character conversion of syslog messages; the directive name is 'syslog_widechar'. Here is a sample usage with two simple PHP scripts.
sample1:
<?php
$message = SOME_UTF8_STRING;
// syslog(LOG_WARNING, $message); // this does not work
ini_set("syslog_widechar", true); // our new directive
syslog(LOG_WARNING, $message); // this works
sample2:
<?php
$message = SOME_ISO_2022_JP_STRING;
syslog(LOG_WARNING, $message); // this works
ini_set("syslog_widechar", true); // our new directive
// syslog(LOG_WARNING, $message); // this does not worksyslog(LOG_WARNING, mb_convert_encoding($message, "UTF-8", "ISO-2022-JP")); // this works
After running these scripts using PHP with this patch, you can see the event messages without any corruptions in Event Viewer. This patch applies cleanly to PHP-5.3.1.
Download: php_syslog-2.patch
--
KITAZAKI Shigeru