Jump to content

What am I doing wrong? Not getting errors in log


ballhogjoni

Recommended Posts

I'm trying to output errors to my log but it's not working. My apache config is as follows:

<VirtualHost *:80>
     ServerName domain.com
     ServerAlias www.domain.us
     DocumentRoot /var/www/html/domain
     <Directory /var/www/html/domain>
         Options +Indexes +FollowSymLinks +ExecCGI
         DirectoryIndex index.php
         AllowOverride All
         Order allow,deny
         Allow from all
     </Directory>
    ErrorLog /var/log/domain_error_log
</VirtualHost>

At the top of my script I have:

error_reporting(E_ALL);
ini_set('display_errors', 1);

I don't want errors on globally so my php.ini errors is set to off. When I go to the script in the browser I get a blank screen with no output to /var/log/domain_error_log. I feel I am missing something but don't know what it is.

I was using the array shorthand code "[]" but didn't realize my box was using php 5.3. I just upgrade to 5.4 and the script works now. I was expecting to get some error relating to the array shorthand code not being valid, maybe a syntax error.

This obviously makes no sense. How do you expect PHP to change the error settings at runtime when it can't even parse the code?

 

You need to configure your error reporting before the script runs. The manual tells you how:

 

http://php.net/manual/en/configuration.changes.php

The Errorlog statement in the VirtualHost block records web server errors.

 

In the script, try adding:

ini_set('log_errors', true);
ini_set('error_log', "phpError.log");

If the script crashes before PHP has a chance to set those settings, also try to add the equivalent statements in the .htaccess file.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.