Reputation: 1559
File structure setup like so,
mainDirectory
-app
--logs
---errors.log
-file.php
Inside of file.php
I have,
ini_set("log_errors", 1);
ini_set("error_log", "logs/errors.log");
I then try to output results like this later,
error_log( print_r($response, TRUE) );
However it just dumps to console. I then tried various checks like
if( file_exists( "logs/errors.log" ) ) {
echo 'yup';
}
else {
echo 'nope';
}
And each time is "nope"
Am I missing something obvious here?
Thank you.
Upvotes: 0
Views: 2369
Reputation: 73
My guess is that you're running into a permissions problem. I'm running Apache on OSX Sierra and my log files are stored in /var/log. If I try to the line below, I get a permission denied
error.
file_put_contents('/var/log/apache2/errors2.log', 'Hello world');
You might consider choosing a location for your error_log that you are certain Apache has permission to write to like /tmp
.
ini_set("error_log", "/tmp/errors.log");
Try using file_put_contents to test the permissions of the directory before using ini_set which can be a bit terse.
Upvotes: 1