MySQL Errors Not Logged in Virtual Host Setup
-
Hi There
Been struggling with this one and done a lot of searching and code history discovery and now I am stuck – hope someone can give me some insight here.
I have a php.ini that applies across all my virtual hosts that has:
log_errors = On
display_errors = Offand error_log is not set because each VirtualHost definition defines the specific ErrorLog file in a location such as:
ErrorLog “/private/var/log/apache2/wpdemo.dev-error_log”
such that Apache picks up the errors spewed out from PHP and sends them to the appropriate log file where the logs are managed/viewed by a specific Console application.
The problem I have is that the MySQL errors from wp-db.php are not logged and in there I find this piece of code that controls the logging:
if ( function_exists( 'error_log' ) && ( $log_file = @ini_get( 'error_log' ) ) && ( 'syslog' == $log_file || @is_writable( $log_file ) ) ) @error_log( $error_str );and now the problem is obvious – because error_log is not set the test result is always false so error_log() is never called.
When I look back in history I find that the genesis of this block of code was introduced (by Ticket 5771) because of some reports about problems with error_log not being supported on some installation (if I am reading the ticket correctly). However, this was 4 years ago and I really wonder whether this is still code that is required?
When I look in WordPress overall I find that the error_log() function is used in multiple places without any such checks and balances so I am really struggling to see why this block of conditional code still exists and why it cannot just be a call to error_log() – like there is a few lines down in the same file where there is no attempt to test whether the file to log to is a writable file and there is no error suppression on the call to error_log().
As it stands in this VirtualHost setup with the host specific log files the MySQL errors can only be made visible in the browser by setting WP_DEBUG to true and this doesn’t really help for logging of errors and it’s impossible to see any errors that happen for non-browser based actions.
I did try specifically setting the error_log value to the required log file path but the file is not writable so that fails also (I don’t feel in this setup it should be necessary to mess with various ownerships and permissions just to get these errors to be able to be logged to a file).
If I set the error_log value to syslog then all the errors from all the sites simply go to the main system log which is not a workable solution.
I can only see the current method working if error_log is set to be a file within the specific site installation but then such a log file is outside of the scope of the Console logging application.
Does anyone know a reason why this block of code has to remain (given all the other ‘uncontrolled’ uses of error_log() or could it just be reverted to a straight call to error_log()?
Thanks for any insight into this.
Regards
The topic ‘MySQL Errors Not Logged in Virtual Host Setup’ is closed to new replies.