I need to log 404 errors and wp-login failed attempts on wordpress site. Unfortunately it natively handles everything and doesn't write to apache log file.
I tried this: 404.php
<?php get_header(); ?>
<div id="post-0" class="post error404 not-found">
<h1><?php _e('Page Not Found', "magazine-basic"); ?></h1>
<div class="storycontent">
<p><?php _e('The page you requested could not be found.', "magazine-basic"); ?></p>
</div><!-- .storycontent -->
</div><!-- #post-0 -->
<?php
error_log("File does not exist: " . rtrim($_SERVER['DOCUMENT_ROOT'], "/") . $_SERVER['REQUEST_URI'], 0);
get_footer();
?>
Functions.php
// Log login errors to Apache error log
add_action('wp_login_failed', 'log_wp_login_fail'); // hook failed login
function log_wp_login_fail($username) {
error_log("WP login failed for username: $username");
}
But it doesn't seem to do the trick. Any thoughts ideas how to do this?