How to log php error in a separate file?











up vote
6
down vote

favorite












I just did an upgrade of my server to Fedora 17 and merged some configuration files containing .rpmnew into the existing ones. I have been successfully logging my php errors in a separate log file by keeping the following in php.ini:



log_errors = On
error_log = /var/log/php-errors.log


I am not sure why the errors are being logged to /var/log/httpd/error_log after the upgrade despite keeping the settings above.



Also,



$ ls -l /var/log/php-errors.log
-rwxrwxr--. 1 apache myself 232 Dec 13 16:49 /var/log/php-errors.log


shows that apache did own the php error log file.



What could be causing PHP errors to be logged into apache error log file?










share|improve this question













migrated from stackoverflow.com Dec 17 '12 at 16:32


This question came from our site for professional and enthusiast programmers.















  • @DaveRandom, from phpinfo(), it shows the loaded config file to be /etc/php.ini, which is correct.
    – Question Overflow
    Dec 17 '12 at 10:55










  • Have you tried setting the permissions on /var/log/php-errors.log to 666, in case the user/groups are not set up how you think they are?
    – DaveRandom
    Dec 17 '12 at 13:49










  • @DaveRandom, thanks for the suggestion. I tried, and it still send the error to apache error log. Even disabling SELinux does not help a bit :(
    – Question Overflow
    Dec 17 '12 at 13:59















up vote
6
down vote

favorite












I just did an upgrade of my server to Fedora 17 and merged some configuration files containing .rpmnew into the existing ones. I have been successfully logging my php errors in a separate log file by keeping the following in php.ini:



log_errors = On
error_log = /var/log/php-errors.log


I am not sure why the errors are being logged to /var/log/httpd/error_log after the upgrade despite keeping the settings above.



Also,



$ ls -l /var/log/php-errors.log
-rwxrwxr--. 1 apache myself 232 Dec 13 16:49 /var/log/php-errors.log


shows that apache did own the php error log file.



What could be causing PHP errors to be logged into apache error log file?










share|improve this question













migrated from stackoverflow.com Dec 17 '12 at 16:32


This question came from our site for professional and enthusiast programmers.















  • @DaveRandom, from phpinfo(), it shows the loaded config file to be /etc/php.ini, which is correct.
    – Question Overflow
    Dec 17 '12 at 10:55










  • Have you tried setting the permissions on /var/log/php-errors.log to 666, in case the user/groups are not set up how you think they are?
    – DaveRandom
    Dec 17 '12 at 13:49










  • @DaveRandom, thanks for the suggestion. I tried, and it still send the error to apache error log. Even disabling SELinux does not help a bit :(
    – Question Overflow
    Dec 17 '12 at 13:59













up vote
6
down vote

favorite









up vote
6
down vote

favorite











I just did an upgrade of my server to Fedora 17 and merged some configuration files containing .rpmnew into the existing ones. I have been successfully logging my php errors in a separate log file by keeping the following in php.ini:



log_errors = On
error_log = /var/log/php-errors.log


I am not sure why the errors are being logged to /var/log/httpd/error_log after the upgrade despite keeping the settings above.



Also,



$ ls -l /var/log/php-errors.log
-rwxrwxr--. 1 apache myself 232 Dec 13 16:49 /var/log/php-errors.log


shows that apache did own the php error log file.



What could be causing PHP errors to be logged into apache error log file?










share|improve this question













I just did an upgrade of my server to Fedora 17 and merged some configuration files containing .rpmnew into the existing ones. I have been successfully logging my php errors in a separate log file by keeping the following in php.ini:



log_errors = On
error_log = /var/log/php-errors.log


I am not sure why the errors are being logged to /var/log/httpd/error_log after the upgrade despite keeping the settings above.



Also,



$ ls -l /var/log/php-errors.log
-rwxrwxr--. 1 apache myself 232 Dec 13 16:49 /var/log/php-errors.log


shows that apache did own the php error log file.



What could be causing PHP errors to be logged into apache error log file?







php apache-http-server error-logging






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 17 '12 at 10:50









Question Overflow

4412722




4412722




migrated from stackoverflow.com Dec 17 '12 at 16:32


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com Dec 17 '12 at 16:32


This question came from our site for professional and enthusiast programmers.














  • @DaveRandom, from phpinfo(), it shows the loaded config file to be /etc/php.ini, which is correct.
    – Question Overflow
    Dec 17 '12 at 10:55










  • Have you tried setting the permissions on /var/log/php-errors.log to 666, in case the user/groups are not set up how you think they are?
    – DaveRandom
    Dec 17 '12 at 13:49










  • @DaveRandom, thanks for the suggestion. I tried, and it still send the error to apache error log. Even disabling SELinux does not help a bit :(
    – Question Overflow
    Dec 17 '12 at 13:59


















  • @DaveRandom, from phpinfo(), it shows the loaded config file to be /etc/php.ini, which is correct.
    – Question Overflow
    Dec 17 '12 at 10:55










  • Have you tried setting the permissions on /var/log/php-errors.log to 666, in case the user/groups are not set up how you think they are?
    – DaveRandom
    Dec 17 '12 at 13:49










  • @DaveRandom, thanks for the suggestion. I tried, and it still send the error to apache error log. Even disabling SELinux does not help a bit :(
    – Question Overflow
    Dec 17 '12 at 13:59
















@DaveRandom, from phpinfo(), it shows the loaded config file to be /etc/php.ini, which is correct.
– Question Overflow
Dec 17 '12 at 10:55




@DaveRandom, from phpinfo(), it shows the loaded config file to be /etc/php.ini, which is correct.
– Question Overflow
Dec 17 '12 at 10:55












Have you tried setting the permissions on /var/log/php-errors.log to 666, in case the user/groups are not set up how you think they are?
– DaveRandom
Dec 17 '12 at 13:49




Have you tried setting the permissions on /var/log/php-errors.log to 666, in case the user/groups are not set up how you think they are?
– DaveRandom
Dec 17 '12 at 13:49












@DaveRandom, thanks for the suggestion. I tried, and it still send the error to apache error log. Even disabling SELinux does not help a bit :(
– Question Overflow
Dec 17 '12 at 13:59




@DaveRandom, thanks for the suggestion. I tried, and it still send the error to apache error log. Even disabling SELinux does not help a bit :(
– Question Overflow
Dec 17 '12 at 13:59










1 Answer
1






active

oldest

votes

















up vote
0
down vote













I think that here it's just the generic Apache errors that are seen in /var/log/httpd/error_log.



I would insert a call to error_log('test'); into some PHP logic that is known to get interpreted when some specific page is refreshed, and if that's not seen in /var/log/php-errors.log then I'd suspect that the versions upgraded to have some kind of a different config or permissions scheme that made the old config stop working.



I'd recommend going through the 'Error handling and logging' section in /etc/php/php.ini, and checking for proper values for other directives. The directive error_reporting should be set to E_ALL or E_ALL & ~E_DEPRECATED & ~E_STRICT. The directive log_errors should be On.



If just a filename (but no path) is specified for error_log, then the file will appear in the same directory as the PHP script that calls error_log(...).



I'd also recommend specifying /tmp/php_error_log for error_log, refreshing the page, and then ls /tmp to see if the file is there.



If the file is not there, login as root, and do a search for the file name across the whole file system so see where it ended up.



Generally, the proper config to get PHP error log working in a particular directory changes across different versions of Apache, PHP, and various distros.



I can say that on Arch Linux with Apache 2.4, PHP 5.5.11 and systemd version 212-1 the config above will make the PHP error log end up somewhere similar to /tmp/systemd-private-65d4c3e3cc534155bcf3ec708c2362f6-httpd.service-h8MSsD/tmp/php_error_log.






share|improve this answer























  • Nope, those are PHP errors, not general errors. And I did give it a full path instead of a relative path. And it used to work two years ago.
    – Question Overflow
    Apr 5 '14 at 6:45











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f520522%2fhow-to-log-php-error-in-a-separate-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













I think that here it's just the generic Apache errors that are seen in /var/log/httpd/error_log.



I would insert a call to error_log('test'); into some PHP logic that is known to get interpreted when some specific page is refreshed, and if that's not seen in /var/log/php-errors.log then I'd suspect that the versions upgraded to have some kind of a different config or permissions scheme that made the old config stop working.



I'd recommend going through the 'Error handling and logging' section in /etc/php/php.ini, and checking for proper values for other directives. The directive error_reporting should be set to E_ALL or E_ALL & ~E_DEPRECATED & ~E_STRICT. The directive log_errors should be On.



If just a filename (but no path) is specified for error_log, then the file will appear in the same directory as the PHP script that calls error_log(...).



I'd also recommend specifying /tmp/php_error_log for error_log, refreshing the page, and then ls /tmp to see if the file is there.



If the file is not there, login as root, and do a search for the file name across the whole file system so see where it ended up.



Generally, the proper config to get PHP error log working in a particular directory changes across different versions of Apache, PHP, and various distros.



I can say that on Arch Linux with Apache 2.4, PHP 5.5.11 and systemd version 212-1 the config above will make the PHP error log end up somewhere similar to /tmp/systemd-private-65d4c3e3cc534155bcf3ec708c2362f6-httpd.service-h8MSsD/tmp/php_error_log.






share|improve this answer























  • Nope, those are PHP errors, not general errors. And I did give it a full path instead of a relative path. And it used to work two years ago.
    – Question Overflow
    Apr 5 '14 at 6:45















up vote
0
down vote













I think that here it's just the generic Apache errors that are seen in /var/log/httpd/error_log.



I would insert a call to error_log('test'); into some PHP logic that is known to get interpreted when some specific page is refreshed, and if that's not seen in /var/log/php-errors.log then I'd suspect that the versions upgraded to have some kind of a different config or permissions scheme that made the old config stop working.



I'd recommend going through the 'Error handling and logging' section in /etc/php/php.ini, and checking for proper values for other directives. The directive error_reporting should be set to E_ALL or E_ALL & ~E_DEPRECATED & ~E_STRICT. The directive log_errors should be On.



If just a filename (but no path) is specified for error_log, then the file will appear in the same directory as the PHP script that calls error_log(...).



I'd also recommend specifying /tmp/php_error_log for error_log, refreshing the page, and then ls /tmp to see if the file is there.



If the file is not there, login as root, and do a search for the file name across the whole file system so see where it ended up.



Generally, the proper config to get PHP error log working in a particular directory changes across different versions of Apache, PHP, and various distros.



I can say that on Arch Linux with Apache 2.4, PHP 5.5.11 and systemd version 212-1 the config above will make the PHP error log end up somewhere similar to /tmp/systemd-private-65d4c3e3cc534155bcf3ec708c2362f6-httpd.service-h8MSsD/tmp/php_error_log.






share|improve this answer























  • Nope, those are PHP errors, not general errors. And I did give it a full path instead of a relative path. And it used to work two years ago.
    – Question Overflow
    Apr 5 '14 at 6:45













up vote
0
down vote










up vote
0
down vote









I think that here it's just the generic Apache errors that are seen in /var/log/httpd/error_log.



I would insert a call to error_log('test'); into some PHP logic that is known to get interpreted when some specific page is refreshed, and if that's not seen in /var/log/php-errors.log then I'd suspect that the versions upgraded to have some kind of a different config or permissions scheme that made the old config stop working.



I'd recommend going through the 'Error handling and logging' section in /etc/php/php.ini, and checking for proper values for other directives. The directive error_reporting should be set to E_ALL or E_ALL & ~E_DEPRECATED & ~E_STRICT. The directive log_errors should be On.



If just a filename (but no path) is specified for error_log, then the file will appear in the same directory as the PHP script that calls error_log(...).



I'd also recommend specifying /tmp/php_error_log for error_log, refreshing the page, and then ls /tmp to see if the file is there.



If the file is not there, login as root, and do a search for the file name across the whole file system so see where it ended up.



Generally, the proper config to get PHP error log working in a particular directory changes across different versions of Apache, PHP, and various distros.



I can say that on Arch Linux with Apache 2.4, PHP 5.5.11 and systemd version 212-1 the config above will make the PHP error log end up somewhere similar to /tmp/systemd-private-65d4c3e3cc534155bcf3ec708c2362f6-httpd.service-h8MSsD/tmp/php_error_log.






share|improve this answer














I think that here it's just the generic Apache errors that are seen in /var/log/httpd/error_log.



I would insert a call to error_log('test'); into some PHP logic that is known to get interpreted when some specific page is refreshed, and if that's not seen in /var/log/php-errors.log then I'd suspect that the versions upgraded to have some kind of a different config or permissions scheme that made the old config stop working.



I'd recommend going through the 'Error handling and logging' section in /etc/php/php.ini, and checking for proper values for other directives. The directive error_reporting should be set to E_ALL or E_ALL & ~E_DEPRECATED & ~E_STRICT. The directive log_errors should be On.



If just a filename (but no path) is specified for error_log, then the file will appear in the same directory as the PHP script that calls error_log(...).



I'd also recommend specifying /tmp/php_error_log for error_log, refreshing the page, and then ls /tmp to see if the file is there.



If the file is not there, login as root, and do a search for the file name across the whole file system so see where it ended up.



Generally, the proper config to get PHP error log working in a particular directory changes across different versions of Apache, PHP, and various distros.



I can say that on Arch Linux with Apache 2.4, PHP 5.5.11 and systemd version 212-1 the config above will make the PHP error log end up somewhere similar to /tmp/systemd-private-65d4c3e3cc534155bcf3ec708c2362f6-httpd.service-h8MSsD/tmp/php_error_log.







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 5 '14 at 1:36









Varaquilex

2,68032046




2,68032046










answered Apr 5 '14 at 0:24









maratbn

112




112












  • Nope, those are PHP errors, not general errors. And I did give it a full path instead of a relative path. And it used to work two years ago.
    – Question Overflow
    Apr 5 '14 at 6:45


















  • Nope, those are PHP errors, not general errors. And I did give it a full path instead of a relative path. And it used to work two years ago.
    – Question Overflow
    Apr 5 '14 at 6:45
















Nope, those are PHP errors, not general errors. And I did give it a full path instead of a relative path. And it used to work two years ago.
– Question Overflow
Apr 5 '14 at 6:45




Nope, those are PHP errors, not general errors. And I did give it a full path instead of a relative path. And it used to work two years ago.
– Question Overflow
Apr 5 '14 at 6:45


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f520522%2fhow-to-log-php-error-in-a-separate-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Probability when a professor distributes a quiz and homework assignment to a class of n students.

Aardman Animations

Are they similar matrix