ballhogjoni Posted April 22, 2014 Share Posted April 22, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/287945-what-am-i-doing-wrong-not-getting-errors-in-log/ Share on other sites More sharing options...
requinix Posted April 22, 2014 Share Posted April 22, 2014 What's in the rest of the script? What kind of errors are you expecting to see logged? Quote Link to comment https://forums.phpfreaks.com/topic/287945-what-am-i-doing-wrong-not-getting-errors-in-log/#findComment-1476976 Share on other sites More sharing options...
ballhogjoni Posted April 22, 2014 Author Share Posted April 22, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/287945-what-am-i-doing-wrong-not-getting-errors-in-log/#findComment-1476978 Share on other sites More sharing options...
Solution Jacques1 Posted April 22, 2014 Solution Share Posted April 22, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/287945-what-am-i-doing-wrong-not-getting-errors-in-log/#findComment-1476980 Share on other sites More sharing options...
ballhogjoni Posted April 22, 2014 Author Share Posted April 22, 2014 Thanks that makes since. Quote Link to comment https://forums.phpfreaks.com/topic/287945-what-am-i-doing-wrong-not-getting-errors-in-log/#findComment-1476981 Share on other sites More sharing options...
bsmither Posted April 22, 2014 Share Posted April 22, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/287945-what-am-i-doing-wrong-not-getting-errors-in-log/#findComment-1476983 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.