PHP's error_log Setting Is Not Working on Windows Apache
When you configure error_reporting = E_ALL | E_STRICT in your .ini file and expect to see output written immediately to a log file, you might encounter a situation where nothing appears. In many environments, this feels like the configuration is simply ignored. However, the behavior often changes drastically depending on whether you are running on Linux or Windows.
The source material highlights a specific failure mode involving Apache 2.2.14 running on Windows with PHP 5.3.0. The user reports that error_log is set in the .ini file but errors do not appear there. Instead, they observe a bizarre side effect: throwing an error causes the Apache server process to restart repeatedly, creating a loop where child processes spawn and die within seconds.
This behavior is not typical of a simple configuration oversight. The log entries provided show the parent process spawning new child processes (e.g., Child 1700, then Child 3656) only for them to exit with status code 128. In Windows, the Apache Multi-Processing Module (MPM) handles concurrency differently than in Unix-like systems. When a PHP script triggers a fatal error or an unhandled exception that causes the process to crash, the MPM attempts to restart the worker. If the underlying cause is not resolved, this results in a cascade of rapid restarts.
The core issue with error_log failing in this context usually stems from two distinct problems: path resolution and buffer flushing.
First, verify the path specified in the error_log directive. On Windows, backslashes (\) are often rejected or misinterpreted unless escaped correctly or converted to forward slashes (e.g., c:\temp\php_errors.log). More critically, if the directory does not exist or the Apache service user lacks write permissions, PHP cannot create the file. Unlike some web servers that might buffer logs until the next request, PHP's default behavior on Windows can be inconsistent regarding immediate flushing of error streams depending on how the server is compiled.
Second, consider the distinction between standard output and the actual log file. If display_errors is set to On, errors are printed to the screen (or browser), which might mask the fact that they are also being logged elsewhere. However, if you see a process restart loop, the error is likely fatal enough to kill the worker thread before the logging mechanism can safely write to disk or because the file handle becomes invalid after the crash.
To resolve this without relying on ini_set() calls inside every script, ensure your .ini configuration is loaded correctly. Check the Apache error log itself (often located in C:\xampp\apache\logs\error.log or similar) for messages like "Failed to open log file" or permission denied errors. You might also need to explicitly set log_errors = On alongside error_log.
If you are using Laravel or a modern PHP stack, rely on the framework's logging channels which can redirect output to various handlers, but understanding these low-level failures is essential for debugging legacy or custom setups. For instance, if you encounter persistent crashes in Apache 2.2 on Windows, switching to a single-threaded MPM configuration or upgrading the server software might be necessary, as older Windows builds of PHP and Apache had known stability issues with error handling that caused exactly this kind of restart loop.
Ultimately, if error_log appears silent while your server is crashing, the problem is rarely about where you point the file path; it is often about whether the process can survive long enough to write to it.