Where Does The PHP Error Log Reside

by Vivek Gite on March 13, 2008 · 4 comments

Q. Can you tell me exact location for php error log file? I'm running CentOS 5.x server with Apache 2.2 + PHP 5.x server.

A. Generally, on all production web servers displaying error to end users via a web browser is turned off using php.ini file settings. Open /etc/php.ini file and find out line that read as follows:
error_log

error_log defines the name of the file where script errors should be logged. The file should be writable by the web server's user. If the special value syslog is used, the errors are sent to the system logger instead. On Unix, this means syslogd and on Windows NT it means the event log. The system logger is not supported on Windows 95. If this directive is not set, errors are sent to the SAPI error logger. For example, it is an error log in Apache (/var/log/httpd/error_log file) or stderr in command line (CLI)

This line define exact location for each php instance. If error_log set to syslog, open /var/log/messages file to view log. For example if error_log is set to /var/log/apache/php.errors, type the following to display error log:
$ tail -f /var/log/apache/php.errors
$ grep something /var/log/apache/php.errors
$ vi /var/log/apache/php.errors

See also:

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 4 comments… read them below or add one }

1 Anthony Thyssen April 7, 2010

The problem with the default set-up on a larger multi-user linux server environment is that System log files are NOT readable by ordinary users. As such it is recommended that users add something like the following to their PHP scripts.

ini_set(‘error_log’, ‘script_errors.log’)
ini_set(‘log_errors’, ‘On’)
ini_set(‘display_errors’, ‘Off’)

Note the file “script_errors.log” may need a full path, and should be writeable by the Apache web server user. That is it should exist with permissions 701 (writeable by others)

Reply

2 Perfector June 15, 2010

What if I’m using lighttpd? Where will I be able to find php logs?

Reply

3 Vivek Gite June 15, 2010

Same location which is defined in your php.ini. It is same for Apache, lighttpd, nginx and so on. See how to configure php.ini for log file.

Reply

4 Boyko January 15, 2012

Hey, this helped me. Thanks much!

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 5 + 13 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: