|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55129 LOG_ level constants don't comply with RFC 3164 on Windows
Submitted: 2011-07-04 11:51 UTC Modified: 2011-07-08 18:18 UTC
Avg. Score:4.0 ± 0.8
Reproduced:6 of 7 (85.7%)
Same Version:5 (83.3%)
Same OS:5 (83.3%)
From: sun at unleashedmind dot com Assigned:
Status: Open Package: Win32API related
PHP Version: Irrelevant OS: Windows
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-07-04 11:51 UTC] sun at unleashedmind dot com
On Windows, the LOG_* constant values differ from the values defined in RFC 3164.  The values are correct on Unix platforms.

Previously discussed in and closed as bogus back in 2002.

Over at Drupal, we replaced custom log level constants with PHP's native LOG_* constants: -- and had to learn the hard way that the constant values differ on Windows. (undocumented:

Drupal uses these severity levels for application-level logging.  The logger is pluggable, so messages may be stored in a database, third-party system, or simply passed to syslog().  Depending on the logger implementation, messages may also be listed/read.  Therefore, consistent log severity level constant values are required.

The question arose why PHP overrides the LOG_* constant values on Windows, kinda violating the RFC, and whether the reduction to values supported by Windows' event log could not happen in a Windows-specific syslog() implementation instead, not affecting the global run-time constants.

I understand that it's Windows that's to blame.  However, I don't see why PHP has to follow Windows' bogus lead on not respecting the RFC.  Conforming to industry standards would be a huge benefit for interoperability with other systems.

Concrete change request:

- Make PHP's LOG_* constant values always conform to RFC 3164.

- Move the platform-specific mapping/reduction into a syslog() implementation for Windows.

Test script:

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-08 18:18 UTC]

I like the idea, perhaps we should cook something like this up together with @fat's patch for multiple connections to syslog() and confront the RFC in and interoperability way in 5.4.
 [2011-11-04 14:34 UTC] panman at traileyes dot com
FYI, just wanted to add that the SimpleSAMLphp project uses these constants as well for their logger.
 [2018-06-12 08:39 UTC] arash dot dalir at gmail dot com
It's 2018 and this issue is still open!
 [2022-01-28 13:33 UTC] john dot portman at gmail dot com
I'm throwing my hat in the ring on this one too but there's a much bigger problem in that syslog() support on Windows is super funky.  Event Viewer is a piece of garbage to begin with by design (thanks Microsoft!) but if PHP is going to interface with it, then it should actually do so rather than some half-baked "I guess Windows exists" sort of implementation.  It's rude/inappropriate to have functionality that only partially works.

A simple:

syslog(LOG_ERR, "This is a test.");

Results in "One or more arguments are invalid" in Event Viewer.  I have to go to the "Details" tab to see the actual message.  Event Viewer doesn't like displaying some types of log messages (LOG_ERR being one of them).

Even when it does display a message (e.g. LOG_NOTICE works slightly better), Event Viewer says, in the "General" tab, "The description for Event ID 2 from source PHP-x.x.x cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer."  There's more to the message but the actual message that was sent shows up after a couple paragraphs of text.  Sending LOG_ERR doesn't show the error message in the "General" tab but LOG_NOTICE seems to be okay-ish.

The Windows event logging system is pretty awful.  Microsoft/Windows requires registering a component to use it "properly," which means registry entries, probably a dedicated DLL, and the like.  Seems to me that there are more significant problems here than just the log levels themselves.  But I also don't have any suggestions on how to fix them other than make sure userland LOG_* identifiers are the same across all platforms and, on Windows, make sure that the "General" tab in Event Viewer always displays the message regardless of log level.  I wouldn't be against PHP putting logs somewhere sane like "%ALLUSERSPROFILE%\php\logs\" if it meant getting a better logging facility than the system Event Viewer.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 13 19:01:30 2024 UTC