« GB18030 support for PHP5.3 | Main | Mio - a distributed Skip Graph based orderd KVS »

Feb 05, 2010

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 work
syslog(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

TrackBack

TrackBack URL for this entry:
http://bb.lekumo.jp/t/trackback/404050/23185297

Listed below are links to weblogs that reference PHP Syslog Patch for Windows (2):

Comments

Post a comment