I can guarantee you, I am not the only person who has been driven to madness at least once in a frustrating search for a log file. It seems like it should be the easiest thing to find in the whole system.
A definitive guide on where php error log is stored would be a complicated bit of work. The official php manual does not even try to address the whole topic, because there are dependencies on systems outside php, such as the operating system (linux vs. Windows, which distro of linux), including settings within Windows and linux that affect name and location of the php error log.
Until someone takes the time to write a complete, cross-system guide, the best you are going to get is general directions where you can inquire. Every php developer has had to endure agony in this pursuit, with one exception. If you work in one place and the information is provided when you first need it, then you have the information need forever, that is, until you find yourself in a new working environment. There are such fortunate people.
If the information is not given to you on a silver platter, so to speak, you have some hunting to do. The hunt is not the longest you will face in your career, but it is not the simplest either.
As is evident from the many answers already posted, a smart place to begin is the output of phpinfo(). To view it, create a php file containing this:
<?php
phpinfo();
Either browse to that file or run it from the command line. If you do both, you likely will find the error_log is in different places, depending on command line vs. web server use of php. That is because the php that runs on a webserver is not the same php that runs from the command line, even when the command line is on the same machine as the web server. The answers already posted in this thread mostly are making an unstated assumption that php is running as part of a web server.
`
The default for error_log is no value
Whatever the value is, it comes from the php.ini files used to configure php. There can be many php.ini files. Finding your way among them is confusing at first, but you do not need to deal with this to find your php log.
If the output from phpinfo() shows a full path to a file, that is where the log is. You are lucky.
The trick is there usually is not a full path indicated in phpinfo(). When there is not a full path, the location depends on:
Whether error_log is no value. If it is, the log file location will depend on the operating system and the mode php is running. If php is running as an apache module, on linux the log often is in /var/log/apache2/error.log Another likely spot is in a logs directory in your account home directory, ~/logs/error.log
If there is a file name without a path, the location depends on whether the file name has the value syslog. If it syslog, then the php error log is injected into the syslog for the server, which varies by linux distro. A common location is /var/log/syslog, but it can be anywhere. Even the name of the syslog varies by distro.
If the name without a path is not syslog, a frequent home for the file is is the document root of the website (a.k.a., website home directory, not to be confused with the home directory for your account).
This cheat sheet has been helpful in some situations, but I regret to have to admit it is not nearly universal. You have my condolences.
/var/log/httpd/error_log
or/var/log/apache2/error.log
. These files are owned by root, so you need to be root or usesudo
to see it, or read it. – Eric Leschinskiphp --info | grep error
– sjasphp --info | findstr /r /c:"error_log"
to see where the log file is. – Boom