Jump to content

What am I doing wrong? Not getting errors in log


Go to solution Solved by Jacques1,

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.

  • Solution

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.