Skip to content
Fox Consulting - Foxco
Blog

Menu

Work

  • clients
  • tools
  • reach
  • news

Tech

  • wordpress
  • shopify
  • woocommerce
  • ecommerce
  • hosting
  • shift4shop

Marketing

  • google ads
  • seo aeo
  • amazon
  • fractional cmo
Foxco//Article

    Written by

    If you'd rather not have to open FTP or SSH to view your error logs and start debugging the free Foxco Wordpress Debug Log Viewer might be of use for you.

    Main Functionality:

    • View WordPress debug.log directly from the admin panel (Tools > Debug Log)
    • Real-time log monitoring with auto-refresh option
    • Syntax highlighting for errors (red), warnings (yellow), and notices (blue/green)
    • Dark theme log display for easy reading

    Controls:

    • Refresh - Manually reload the log
    • Auto-Refresh - Toggle automatic refresh every 5 seconds
    • Download - Download the current log file
    • Clear Log - Empty the debug log file

    Filters:

    • Toggle visibility of errors, warnings, and notices
    • Search/filter log entries in real-time
    • Adjustable line limit (50-10000 lines)

    Info Display:

    • Shows if debug.log exists
    • File size
    • WP_DEBUG status
    • WP_DEBUG_LOG status
    • Helpful notice if debugging isn't enabled

    The plugin uses a clean, modern interface with responsive design and includes helpful syntax highlighting to make debugging easier.

    Like everything Foxco does this plugin is dead-simple, clean and fast.. only 232 lines of code.

    Click here to download the installable zip file.

    <?php
    /**
     * Plugin Name: Foxco Debug Log Viewer
     * Plugin URI: https://www.foxco.net
     * Description: Simple debug.log viewer for WordPress with real-time monitoring and log management
     * Version: 1.0.0
     * Author: Foxco
     * Author URI: https://www.foxco.net
     * License: GPL v2 or later
     * Text Domain: foxco-debug-viewer
     */
    
    // Prevent direct access
    if (!defined('ABSPATH')) {
        exit;
    }
    
    class Foxco_Debug_Log_Viewer {
        
        private $log_file;
        
        public function __construct() {
            $this->log_file = WP_CONTENT_DIR . '/debug.log';
            
            // Add admin menu
            add_action('admin_menu', array($this, 'add_admin_menu'));
            
            // AJAX handlers
            add_action('wp_ajax_foxco_get_log', array($this, 'ajax_get_log'));
            add_action('wp_ajax_foxco_clear_log', array($this, 'ajax_clear_log'));
            add_action('wp_ajax_foxco_download_log', array($this, 'ajax_download_log'));
            
            // Admin scripts
            add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
        }
        
        public function add_admin_menu() {
            add_management_page(
                'Debug Log Viewer',
                'Debug Log',
                'manage_options',
                'foxco-debug-log',
                array($this, 'render_admin_page')
            );
        }
        
        public function enqueue_scripts($hook) {
            if ($hook !== 'tools_page_foxco-debug-log') {
                return;
            }
            
            wp_enqueue_style(
                'foxco-debug-viewer',
                plugin_dir_url(__FILE__) . 'assets/style.css',
                array(),
                '1.0.0'
            );
            
            wp_enqueue_script(
                'foxco-debug-viewer',
                plugin_dir_url(__FILE__) . 'assets/script.js',
                array('jquery'),
                '1.0.0',
                true
            );
            
            wp_localize_script('foxco-debug-viewer', 'foxcoDebugViewer', array(
                'ajax_url' => admin_url('admin-ajax.php'),
                'nonce' => wp_create_nonce('foxco_debug_viewer')
            ));
        }
        
        public function render_admin_page() {
            if (!current_user_can('manage_options')) {
                wp_die(__('You do not have sufficient permissions to access this page.'));
            }
            
            $log_exists = file_exists($this->log_file);
            $log_size = $log_exists ? size_format(filesize($this->log_file), 2) : '0 B';
            $wp_debug_enabled = defined('WP_DEBUG') && WP_DEBUG;
            $wp_debug_log_enabled = defined('WP_DEBUG_LOG') && WP_DEBUG_LOG;
            
            ?>
            <div class="wrap foxco-debug-viewer">
                <h1>
                    <span class="dashicons dashicons-admin-tools"></span>
                    Foxco Debug Log Viewer
                </h1>
                
                <div class="foxco-debug-header">
                    <div class="foxco-debug-info">
                        <div class="info-item">
                            <strong>Log File:</strong> 
                            <?php echo $log_exists ? '<span class="status-active">Active</span>' : '<span class="status-inactive">Not Found</span>'; ?>
                        </div>
                        <div class="info-item">
                            <strong>File Size:</strong> <?php echo esc_html($log_size); ?>
                        </div>
                        <div class="info-item">
                            <strong>WP_DEBUG:</strong> 
                            <?php echo $wp_debug_enabled ? '<span class="status-active">Enabled</span>' : '<span class="status-inactive">Disabled</span>'; ?>
                        </div>
                        <div class="info-item">
                            <strong>WP_DEBUG_LOG:</strong> 
                            <?php echo $wp_debug_log_enabled ? '<span class="status-active">Enabled</span>' : '<span class="status-inactive">Disabled</span>'; ?>
                        </div>
                    </div>
                    
                    <div class="foxco-debug-actions">
                        <button id="foxco-refresh-log" class="button button-primary">
                            <span class="dashicons dashicons-update"></span> Refresh
                        </button>
                        <button id="foxco-auto-refresh" class="button" data-active="0">
                            <span class="dashicons dashicons-backup"></span> Auto-Refresh: OFF
                        </button>
                        <button id="foxco-download-log" class="button">
                            <span class="dashicons dashicons-download"></span> Download
                        </button>
                        <button id="foxco-clear-log" class="button button-secondary">
                            <span class="dashicons dashicons-trash"></span> Clear Log
                        </button>
                    </div>
                </div>
                
                <?php if (!$wp_debug_enabled || !$wp_debug_log_enabled): ?>
                <div class="notice notice-warning">
                    <p>
                        <strong>Debug logging is not fully enabled.</strong> 
                        To enable debug logging, add these lines to your wp-config.php file:
                    </p>
                    <pre>define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);</pre>
                </div>
                <?php endif; ?>
                
                <div class="foxco-debug-controls">
                    <label>
                        <input type="checkbox" id="foxco-filter-errors" checked> 
                        Show Errors
                    </label>
                    <label>
                        <input type="checkbox" id="foxco-filter-warnings" checked> 
                        Show Warnings
                    </label>
                    <label>
                        <input type="checkbox" id="foxco-filter-notices" checked> 
                        Show Notices
                    </label>
                    <label>
                        <input type="number" id="foxco-line-limit" min="50" max="10000" step="50" value="500">
                        Lines to Display
                    </label>
                    <input type="text" id="foxco-search" placeholder="Search log..." />
                </div>
                
                <div id="foxco-log-container" class="foxco-log-container">
                    <div class="foxco-loading">Loading debug log...</div>
                </div>
            </div>
            <?php
        }
        
        public function ajax_get_log() {
            check_ajax_referer('foxco_debug_viewer', 'nonce');
            
            if (!current_user_can('manage_options')) {
                wp_send_json_error('Insufficient permissions');
            }
            
            $lines = isset($_POST['lines']) ? intval($_POST['lines']) : 500;
            
            if (!file_exists($this->log_file)) {
                wp_send_json_success(array(
                    'content' => 'No debug log found. Debug logging may not be enabled.',
                    'size' => 0,
                    'modified' => ''
                ));
            }
            
            $content = $this->get_log_tail($lines);
            
            wp_send_json_success(array(
                'content' => $content,
                'size' => size_format(filesize($this->log_file), 2),
                'modified' => date('Y-m-d H:i:s', filemtime($this->log_file))
            ));
        }
        
        public function ajax_clear_log() {
            check_ajax_referer('foxco_debug_viewer', 'nonce');
            
            if (!current_user_can('manage_options')) {
                wp_send_json_error('Insufficient permissions');
            }
            
            if (file_exists($this->log_file)) {
                file_put_contents($this->log_file, '');
                wp_send_json_success('Log file cleared successfully');
            } else {
                wp_send_json_error('Log file not found');
            }
        }
        
        private function get_log_tail($lines = 500) {
            if (!file_exists($this->log_file)) {
                return '';
            }
            
            $file = new SplFileObject($this->log_file, 'r');
            $file->seek(PHP_INT_MAX);
            $total_lines = $file->key() + 1;
            
            $start_line = max(0, $total_lines - $lines);
            
            $content = array();
            $file->seek($start_line);
            
            while (!$file->eof()) {
                $line = $file->current();
                if ($line !== false) {
                    $content[] = $line;
                }
                $file->next();
            }
            
            return implode('', $content);
        }
    }
    
    // Initialize plugin
    new Foxco_Debug_Log_Viewer();
    
    bottom dock header
    Uncategorized

    The Bottom Dock Header and why we love it

    10/21/2026 — andy fox
    Wordpress Broken FixWP
    Business

    Why we Built FixWP (Fix WordPress)

    09/16/2026 — andy fox
    Why do Squarespace Wix Airo & other AI websites look so cheap?
    CSS

    Why do Squarespace Wix Airo & other AI websites look so cheap?

    09/15/2026 — andy fox
    Do Deactivated WordPress Plugins Slow Down My Site?
    Help Tickets

    Do deactivated WordPress plugins slow down my site?

    09/12/2026 — andy fox
    Why hire a microagency
    Data

    Why Hire A Microagency In 2026

    09/01/2026 — andy fox
    Wordpress Admin Email Save
    Plugins

    Change WordPress Admin Email Without Confirming (Plugin)

    07/15/2026 — andy fox
    Your Product Files Suck
    Data

    Brands: Your Product File Sucks

    06/26/2026 — andy fox
    A Box Nerd’s Guide to eCommerce Packaging
    Data

    A Box Nerd’s Guide to eCom Packaging

    05/09/2026 — andy fox
    1 2 3 … 18 →

    WORK

    our genius clients

    Annenberg
    Mishimoto
    Saleen
    Troika
    RainX
    Cheapi
    Batts.biz
    Ustream
    NOCO
    Tiger Battery
    Eastwood
    Continental
    BBOS
    22OR
    Annenberg
    Mishimoto
    Saleen
    Troika
    RainX
    Cheapi
    Batts.biz
    Ustream
    NOCO
    Tiger Battery
    Eastwood
    Continental
    BBOS
    22OR
    Annenberg
    Mishimoto
    Saleen
    Troika
    RainX
    Cheapi
    Batts.biz
    Ustream
    NOCO
    Tiger Battery
    Eastwood
    Continental
    BBOS
    22OR

    TECH

    technologies we love

    React JS
    Ghost CMS developer
    HTML5 PHP
    WooCommerce
    Wordpress
    Shopify
    Python
    Magento
    BigCommerce
    GatsbyJS
    Shift4Shop
    Meta
    Amazon
    Epicor
    Klaviyo
    Drupal
    Zapier
    React JS
    Ghost CMS developer
    HTML5 PHP
    WooCommerce
    Wordpress
    Shopify
    Python
    Magento
    BigCommerce
    GatsbyJS
    Shift4Shop
    Meta
    Amazon
    Epicor
    Klaviyo
    Drupal
    Zapier
    React JS
    Ghost CMS developer
    HTML5 PHP
    WooCommerce
    Wordpress
    Shopify
    Python
    Magento
    BigCommerce
    GatsbyJS
    Shift4Shop
    Meta
    Amazon
    Epicor
    Klaviyo
    Drupal
    Zapier

    Big Agency Depth + Micro Agency Focus.

    Big agencies bring big-brand experience, and small teams bring agility and a sharp focus on your niche -- Foxco is an Arizona micro agency that gives you both. With 500+ companies and 100+ years of combined experience in competitive markets behind us, you work directly with senior people, get decisions made fast, and get the kind of expert, hands-on execution big agencies just aren't built to deliver.

    Ask your doctor if hiring a microagency is right for you

    Foxco - Made in the USA

    Arizona
    Built

    serving businesses coast to coast & beyond

    Foxco is a microagency built around uncommon experience and skills. Foxco is centrally based in Phoenix Arizona and has served 500+ clients across the US and beyond with 100+ combined years of Big Agency level experience paired with unmatched skills, focus and agility.

    500+
    companies served
    100+
    years combined experience
    100%
    US-based team
    0%
    sales pressure
    LET'S CHAT
    Consulting eCom Wordpress Shopify $999 Website Google Amazon Fractional CMO Fix Wordpress
    PhoneEmailFoxco NewsFacebookYoutubeWhatsappPrivacy PolicyAccessibilityWordpress Hosting